ZKX's LAB

从键盘输入若干行 1、编程实现:从键盘输入的若干字符中,以换行结束输入,统计处其中消协字母的个数。

2021-04-27知识0

C++缠着程序用户从键盘输入若干行字符串,每输入一行就将其写入一个文本文件中,直到用户输入end才 include#include#includeusing namespace std;int main(){ string temp;ofstream out(\"out.txt\");写入 cout输入字符开始写入:;do{ getline(cin,temp);out;} while(temp。。

1、编程实现:从键盘输入的若干字符中,以换行结束输入,统计处其中消协字母的个数。 4.program t1;vars:string;beginwriteln;write('s=');readln(s);write(s);n:=length(s);for i:=n-1 downto 1 dowrite(s[i]);end.

从键盘输入若干行字符,将每一行加行号后保存到c:\\abc.dat文件中.然后在显示c:\\ab 拍入几行字符,空行结束。写入文件调DOS命令 type 显示文件内容。includeincludemain(){FILE*fp;char s[100];int i,n=1;fp=fopen(\"C:\\\\abc.dat\",\"w\");printf(\"input several line characters,and blank line as end\\n\");while(1){gets(s);if(strlen(s)=0)break;fprintf(fp,\"%d%s\\n\",n,s);n+;}fclose(fp);system(\"type C:\\\\abc.dat\");return 0;}

#从键盘输入若干行

随机阅读

qrcode
访问手机版