您好,欢迎访问三七文档
文件读写从键盘输入成绩,写入文件data.txt,输入q结束。打开同一文件data.txt,读文件数据,打印累加和样例607080q210#includestdafx.h#includefstream#includeiostreamusingnamespacestd;intmain(intargc,char*argv[]){intx;intsum=0;ifstreaminfile;ofstreamoutfile;outfile.open(data.txt);while(cinx){outfilex;}outfile.close();infile.open(data.txt);while(infilex){sum+=x;}infile.close();coutsum;return0;}
本文标题:C++作业程序
链接地址:https://www.777doc.com/doc-4948271 .html