Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void beolvasas(int pp_mat[][50], int& n) {
- ifstream fin("boole.txt");
- fin >> n;
- int i, j;
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++)
- fin >> pp_mat[i][j];
- }
- }
- void pp_mat_ki(int pp_mat[][50], int n) {
- int i, j;
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++)
- cout << pp_mat[i][j] << ' ';
- cout << endl;
- }
- }
- void ell_mat_tolt(int pp_mat[][50], int ell_mat[][2], int n) {
- int i, j, ell_index = 0;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (pp_mat[i][j]) {
- ell_mat[ell_index][0] = i+1;
- ell_mat[ell_index][1] = j+1;
- ell_index++;
- }
- }
- }
- }
- int el_szamitas(int pp_mat[][50], int n) {
- int m = 0;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (pp_mat[i][j]) {
- m++;
- }
- }
- }
- return m;
- }
- void ell_mat_ki(int ell_mat[][2], int m) {
- for (int i = 0; i < m; i++) {
- cout << ell_mat[i][0] << ' ' << ell_mat[i][1] << endl;
- }
- }
- int main()
- {
- int pp_mat[50][50], n;
- beolvasas(pp_mat, n);
- pp_mat_ki(pp_mat, n);
- cout << endl << endl;
- int ell_mat[50][2],m;
- m = el_szamitas(pp_mat, n);
- ell_mat_tolt(pp_mat, ell_mat, n);
- ell_mat_ki(ell_mat, m);
- }
Advertisement
Add Comment
Please, Sign In to add comment