Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- #include <windows.h>
- using namespace std;
- const int t = 5;
- const int lengthColumn = 20;
- const int Indent = 7;
- const int lengthTable = 106;
- void star1(ofstream &f, int n, int m)
- {
- f.width(n);
- int i;
- for (i = 0; i<m; i++)
- f << '*';
- f << endl;
- }
- void star2(ofstream &f, int n, int m)
- {
- f.width(n);
- int i;
- for (i = 0; i<m; i++)
- f << '*';
- }
- void table(ifstream &fin1, ifstream &fin2, ofstream &f, int m, int a[4][5], char s1[16])
- {
- int i;
- for (i = 0; i<m; i++)
- {
- if (i == 0)
- {
- star1(f,Indent + 1, lengthTable);
- f.width(Indent + 1); f << '*';
- f.width(lengthColumn + 1); f << '*';
- for (int j = 0; j<t - 1; j++)
- {
- f.width(15);
- fin2 >> s1; f << s1;
- memset(s1, ' ', 16);
- star2(f,t + 1, 1);
- }
- f << endl;
- }
- else
- {
- star1(f,Indent + 1, lengthTable);
- star2(f,Indent + 1, 1);
- f.width(15);
- fin2 >> s1; f << s1;
- memset(s1, ' ', 16);
- star2(f,t + 1, 1);
- for (int j = 0; j<t - 1; j++)
- {
- f.width(11); fin1 >> a[j][i - 1];
- f << a[j][i - 1]; star2(f,10, 1);
- }
- f << endl;
- }
- }
- star1(f,Indent + 1, lengthTable);
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int matrix[t - 1][t] = { 0 };
- int sr;
- char s[16];
- int sum = 0;
- ifstream fin1("Text.txt");
- string str;
- cout << "Введите название";
- getline(cin, str);
- ifstream fin2("input1.txt");
- ofstream out("Text1.txt");
- out << endl;
- out.width(Indent + 57);
- out << str;
- out.width(lengthTable - 57);
- out << endl;
- table(fin1, fin2,out, t + 1, matrix, s);
- out.width(Indent + 1);
- out << '*';
- out.width(18); out << "СРЕДНЕЕ ЗНАЧЕНИЕ";
- star2(out,Indent -4, 1);
- fin1.close();
- fin2.close();
- for (int i = 0; i<t - 1; i++)
- {
- out.width(11);
- for (int j = 0; j < t; j++)
- sum += matrix[i][j];
- sr = sum / 5;
- out << sr; star2(out,10, 1);
- sr = 0;
- }
- out << endl;
- star1(out,Indent + 1, lengthTable);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment