自考新教材-p279_1

源程序:

#include <iostream>

using namespace std;

int main()

{

int x, y;

cin >> x >> y;

freopen("c:\\test.txt", "w", stdout); 

if (y == 0)                            

cerr<<"error."<<endl;

else

cout << x << "/" << y << "=" << x / y << endl;

system("pause");

return 0;

}

 运行结果:

输入:9 3

在c盘上产生文本文件test.txt,内容为:9/3=3

posted @ 2020-01-27 12:09  bobo哥  阅读(108)  评论(0编辑  收藏  举报