Created
April 4, 2020 08:41
-
-
Save ryuchan00/a93cdd8ecd1e630a8b249e77f033f245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int i = 0; | |
// 今は入力値は101を与えてあげる。出力は1が文字列中に2つなので2になる | |
char *str = "101"; | |
int counter = 0; // strに1が何回あるか数える変数 | |
while (※strの文字列の長さの回数繰り返す) | |
{ | |
if (※strのi+1文字目が「1」かどうか) { // iは0から開始するが、日本語にすると「i + 1」という表現になる為注意 | |
counter++; | |
} | |
i++; | |
} | |
printf("%d\n", counter); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment