一维字符数组(.pptVIP

  • 21
  • 0
  • 约5.18千字
  • 约 20页
  • 2018-12-27 发布于江苏
  • 举报
一维字符数组(

第10章 字符串 10.4.6 字符数组应用举例 例1字符串排序,要求输入5个学生的名字,按字母升序输出: int main() { char name[5][10],buff[100]; int i,j,k,n=0; for(i=0;i5;i++) { printf(“please input the name of %d th student:\n”,i+1); gets(buff); if(strlen(buff)10) { printf(“the length of the name is larger than 10\n”); continue; } strcpy(name[i],buff); } /*10-8 a 输入一行字,统计其中有多少个单词,单词间是空格分开*/ #include stdio.h void main ( ) { char c; int i = 0 ,num = 0 ,word=0; char str[81]; gets ( str ); for(i=0;(c=str[i])!=\0;i++) if ( c == ) word=0; else if(word==0) { word=1; num++; } printf

文档评论(0)

1亿VIP精品文档

相关文档