自考新教材-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

原文地址:https://www.cnblogs.com/duanqibo/p/12235657.html