从键盘输入若干行字符,将其存入“s8”磁盘文件中,再从文件中读取这些字符, #includeincludedefine MAXLINE 512void input(char*a){gets(a);}void wr(char*file,char*a){FILE*fp;if((fp=fopen(file,\"w\"))=NULL){printf(\"can not open output file。exit(-1);}fputs(a,fp);fclose(fp);}void rd(char*file,char*a){FILE*fp;if((fp=fopen(file,\"r\"))=NULL){printf(\"can not open input file。exit(-2);}while。feof(fp)){if(fgets(a,MAXLINE,fp)){char*p=a;while(*p){if(*p>;='A'&*p)*p+32;p+;}puts(a);}}fclose(fp);}int main(){char a[MAXLINE];input(a);wr(\"s8\",a);rd(\"s8\",a);return 0;}
C++缠着程序用户从键盘输入若干行字符串,每输入一行就将其写入一个文本文件中,直到用户输入end才 include#include#includeusing namespace std;int main(){ string temp;ofstream out(\"out.txt\");写入 cout输入字符开始写入:;do{ getline(cin,temp);out;} while(temp。。
c语言编程:从键盘输入若干字符,以换行结束输入,统计出其中小写字母的个数。 /*输入一串字符,统计数字字符、大小写字母字符和7a64e4b893e5b19e31333264636261其它字符的个数。includeincludevoid main(){char ch[50];int i,j=0,k=0,m=0,n=0;printf(\"请输入一串字符:\");gets(ch);printf(\"输入的字符为:\");puts(ch);for(i=0;i(ch);i+){if(ch[i]>;='0'&ch[i]){j+;}else if(ch[i]>;='a'&ch[i]){k+;}else if(ch[i]>;='A'&ch[i]){n+;}else if(ch[i]|ch[i]>;'9'&ch[i]|ch[i]>;'Z'&ch[i]|ch[i]>;'z'){m+;}}printf(\"数字个数为:%d\\n\",j);printf(\"小写字母个数为:%d\\n\",k);printf(\"大写字母个数为:%d\\n\",n);printf(\"其他字符个数为:%d\\n\",m);}