第一题
#include <stdio.h>
#include <ctype.h>
main()
{ int num[26],i;
char c;
for (i=0;i<26;i++) num[i]=0;
while ((c=getchar())!=' ')
if (isupper(c)) num[c-65]+=1;
for (i=0;i<26;i++)
if (num[i]) printf("%c:%d\n",i+65,num[i]);
}
第一题的其他版本
#include<stdio.h>
void main()
{
int i=0,j=0,k;
char a[100];
scanf("%s",&a);
while(a[i]!='\0')
{ i++;
if(a[i]>65&&a[i]<90)
j++;}
printf("%d",j);
}
程序填空
1. long fun(long x);
2. fun(n)
3. x*x + fun(x-1)
改错题:
注意:改错和填空要将整个程序抄下来,不要只写空!
1、n=3*A*1000+4*100+B*10+5 改为 n=3*10000+A*1000+4*100+B*10+5
2、if(n\178<193) 改为 if(n/178<193)
3、continue 改为 break