c+1
i+1
c
改错:
scanf("%s",str);
count=count+1
1、填空题
#include <stdio.h>
void main()
{
int i,c;
c=0;
i=1;
while(i<2021)
{
if(i%8==0 || i%10 == 8 || i/10%10 == 8 || i/100%10 == 8)
c = c+1;
i=i+1;
}
printf("c=%d\n",c);
}
2、改错题:
#include <stdio.h>
void main()
{
char str[100];
int i,count;
printf("Input a string:\n");
scanf("%s",str);
count = 0;
i = 0;
while(str[i] != '\0')
{
if(str[i] >= '0' && str[i] <= '9')
count += 1;
i++;
}
printf("%d\n",count);
}