#include <stdio.h>
#include <conio.h>
#include <string.h>
void lsdo (void);
void word (void);
void largest (void);
void main (void)
{
printf("please input some characters\n");
char lsdo;
char word;
char largest;
return ;
}
void lsdo (void)
{
char c;
int letters=0,space=0,digit=0,others=0;
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,
space,digit,others);
}
void word (void)
{
char string[100];
int i,num=0,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!='\0';i++)
if(c==' ') word=0;
else if (word==0)
{
word=1;
num++;
}
printf("There are %d words in the line.\n",num);
}
void largest (void)
{
char string[20];
char str[3][20];
int i;
for(i=0;i<10;i++)
gets (str[i]);
if(strcpy(str[0],str[1])>0)
strcpy(string,str[0]);
else
strcpy(string,str[1]);
if (strcmp(str[2],string)>0)
strcpy(string,str[2]);
printf("\nThe laegest string is:\n",string);
}
我给别人写的....功能有点乱...