5A_6
This commit is contained in:
		
							parent
							
								
									27c3768c07
								
							
						
					
					
						commit
						1c59d193f2
					
				| 
						 | 
				
			
			@ -139,7 +139,7 @@
 | 
			
		|||
    </Link>
 | 
			
		||||
  </ItemDefinitionGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ClCompile Include="ConsoleApplication2.cpp" />
 | 
			
		||||
    <ClCompile Include="ConsoleApplication3.cpp" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 | 
			
		||||
  <ImportGroup Label="ExtensionTargets">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
    </Filter>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ClCompile Include="ConsoleApplication2.cpp">
 | 
			
		||||
    <ClCompile Include="ConsoleApplication3.cpp">
 | 
			
		||||
      <Filter>Source Files</Filter>
 | 
			
		||||
    </ClCompile>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,74 @@
 | 
			
		|||
#include <iostream>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
class Matrix {
 | 
			
		||||
	static const int n = 10;
 | 
			
		||||
 | 
			
		||||
	int tab[n][n];
 | 
			
		||||
public:
 | 
			
		||||
	void czytaj_dane() {
 | 
			
		||||
		int k = 0;
 | 
			
		||||
		for (int i = 0; i < n; i++) {
 | 
			
		||||
			for (int j = 0; j < n; j++) {
 | 
			
		||||
				tab[i][j] = k++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void wyswietl() {
 | 
			
		||||
		for (int i = 0; i < n; i++) {
 | 
			
		||||
			for (int j = 0; j < n; j++) {
 | 
			
		||||
				cout << tab[i][j] << '\t';
 | 
			
		||||
			}
 | 
			
		||||
			cout << endl;
 | 
			
		||||
		}
 | 
			
		||||
		cout << endl << endl;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void przetworz_dane() {
 | 
			
		||||
		for (int i = 0; i < n; i++) {
 | 
			
		||||
			for (int j = 0; j < n; j++) {
 | 
			
		||||
				if(i > j) swap(tab[i][j], tab[j][i]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void zapisz_dane_do_pliku() {
 | 
			
		||||
		fstream f;
 | 
			
		||||
		f.open("dane.txt");
 | 
			
		||||
		for (int i = 0; i < n; i++) {
 | 
			
		||||
			for (int j = 0; j < n; j++) {
 | 
			
		||||
				f << tab[i][j] << '\t';
 | 
			
		||||
			}
 | 
			
		||||
			f << endl;
 | 
			
		||||
		}
 | 
			
		||||
		f.close();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void czytaj_dane_z_pliku() {
 | 
			
		||||
		fstream f;
 | 
			
		||||
		f.open("dane.txt");
 | 
			
		||||
 | 
			
		||||
		while (!f.eof()) {
 | 
			
		||||
			string s;
 | 
			
		||||
			getline(f, s);
 | 
			
		||||
			cout << s << endl;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f.close();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
	Matrix m;
 | 
			
		||||
	m.czytaj_dane();
 | 
			
		||||
	m.wyswietl();
 | 
			
		||||
	m.przetworz_dane();
 | 
			
		||||
	m.wyswietl();
 | 
			
		||||
	m.zapisz_dane_do_pliku();
 | 
			
		||||
	m.czytaj_dane_z_pliku();
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue