#include #define maxn 10000000+10 int main() { char s[maxn]; scanf("%s", s); int tot = 0; for (int i = 0; i < strlen(s);i++) if (s[i] == 1) tot++; printf("%d\n",tot); return 0; } 书上说至少有三个错误。程序无法运行是啥原因,结果不对也没找到原因,还有效率低下也不知道啥原因,好崩溃啊!各位大侠帮帮忙,我
#include <stdio.h>
#include <string.h>
#define maxn 10000000+10
char s[maxn];
int main()
{
int tot = 0;
int i;
scanf("%s", s);
for (i = 0; i < strlen(s);i++)
if (s[i] == '1')
tot++;
printf("%d\n",tot);
return 0;
}
#include <stdio.h>
#include <string.h>
#define maxn 10000000+10
char s[maxn];
int main()
{
int tot = 0;
int i;
scanf("%s", s);
for (i = 0; i < strlen(s);i++)
if (s[i] == '1')
tot++;
printf("%d\n",tot);
return 0;
}
#include <stdio.h>
#include <string.h>
#define maxn 10000000+10
char s[maxn];
int main()
{
int tot = 0;
int i;
scanf("%s", s);
for (i = 0; i < strlen(s);i++)
if (s[i] == '1')
tot++;
printf("%d\n",tot);
return 0;
}
#include <stdio.h>
#include <string.h>
#define maxn 10000000+10
char s[maxn];
int main()
{
int tot = 0;
int i;
scanf("%s", s);
for (i = 0; i < strlen(s);i++)
if (s[i] == '1')
tot++;
printf("%d\n",tot);
return 0;
}