现在的位置: 首页 > 14 二级C语言 > 正文

2011春江苏省二级C上机真题C02 改错题

2011年09月06日 14 二级C语言 ⁄ 共 457字 ⁄ 字号 暂无评论
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int count (char p[],char pmax[])
{
    int j=0,k,m=0;
    char temp[100];
    while(*p) {
        while((!isalpha(*p))&&*p) p++;
        k=0;
        if(*p!='\0') m++;
        while(isalpha(*p))
            temp[k++]=*p++;
        temp[k]= "\0";
        if(k<j) {
            j=k;
            pmax=temp;
        }
    }
    return m;
}
 
void main()
{
    char a[100]="you  are  teacher234too.",max[100];
    int i;
    i=count(a[],max[]);
    if(i==0)
        printf("a=%s N0 letter string!\n",a);
    else
        printf("a=%s\nnumber is %d\nmax string:%s\n",a,i,max);
}

抱歉!评论已关闭.