文件读写从键盘输入成绩,写入文件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;}