一.问题描述

建立文件M99.txt,并在其中输入乘法口诀表,同时打印在屏幕上,格式如下:

要求屏幕上和文档中的输出一致。

二.设计思路

三.流程图

四.伪代码 

1

五.代码实现 

#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
using namespace std;
int main() {
	/*ofstream file("C:\\M99.txt");
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= i; j++) {
			file << i << "*" << j << "=" <<setw(2)<< i * j << " ";
		}
		file << endl;
	}*/
	ifstream file1("C:\\M99.txt");
	char s[1000];
	while (file1.getline(s, 1000)) {
		cout << s << endl;
	}
	return 0;
}

 

posted on 2023-05-15 23:18  leapss  阅读(31)  评论(0)    收藏  举报