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