Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <iomanip>
- #define MN 31
- int N=0;//élek szama
- double A[MN][MN];//csucsmatrix
- int a3;
- using namespace std;
- void beolvas(char *fnev)
- {
- ifstream f;
- f.open(fnev);
- int a1,a2;
- f>>a1>>a2>>a3;
- N=a1;
- switch(a2)
- {
- case 1 : //csucsmatrix
- {
- for(int i=1;i<=N;i++)
- {
- for(int j=1;j<=N;j++)
- {
- f>>A[i][j];
- }
- }
- break;
- }
- case 2 :
- {
- int cs,szn,sz;
- for(int n=1;n<=N;n++)
- {
- f>>cs>>szn;
- for(int i=1;i<=szn;i++)
- {
- f>>sz;
- if(a3==1 || a3==2) A[cs][sz]=1;
- else
- {
- double suly;
- f>>suly;
- A[cs][sz]=suly;
- }
- }
- }
- break;
- }
- case 3:
- {
- int esz;
- f>>esz;
- for(int i=1;i<=N;i++)
- {
- int cs1,cs2;
- double suly;
- if(a3==3 || a3==4)f>>cs1>>cs2>>suly;
- else
- {
- f>>cs1>>cs2;
- suly=1;
- }
- A[cs1][cs2]=suly;
- if(a3==1 || a3==3) A[cs2][cs1]=suly;
- }
- break;
- }
- default:
- {
- cout<<"HIBA"<<endl;
- }
- }
- f.close();
- }
- void nullaz1D(int x[],int meret)
- {
- for(int i=0;i<meret;i++) x[i]=0;
- }
- void nullaz2D(double x[][MN],int meret)
- {
- for(int i=0;i<meret;i++)
- {
- for(int j=0;j<meret;j++)
- {
- x[i][j]=0;
- }
- }
- }
- int befokszam(int n)
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- if(A[n][i]!=0) s++;
- }
- return s;
- }
- int kifokszam(int n)
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- if(A[i][n]!=0) s++;
- }
- return s;
- }
- int maxbefokszam()
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- int t=0;
- for(int j=1;j<=N;j++)
- {
- if(A[i][j]!=0) t++;
- }
- if(t>s) s=t;
- }
- return s;
- }
- int maxkifokszam()
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- int t=0;
- for(int j=1;j<=N;j++)
- {
- if(A[j][i]!=0) t++;
- }
- if(t>s) s=t;
- }
- return s;
- }
- int minbefokszam()
- {
- int s=31;
- for(int i=1;i<=N;i++)
- {
- int t=0;
- for(int j=1;j<=N;j++)
- {
- if(A[i][j]!=0) t++;
- }
- if(t<s) s=t;
- }
- return s;
- }
- int minkifokszam()
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- int t=0;
- for(int j=1;j<=N;j++)
- {
- if(A[j][i]!=0) t++;
- }
- if(t<s) s=t;
- }
- return s;
- }
- int izolaltcs()
- {
- int s=0;
- for(int i=1;i<=N;i++)
- {
- int t1=0;
- int t2=0;
- for(int j=1;j<=N;j++)
- {
- if(A[i][j]!=0) t1++;
- if(A[j][i]!=0) t2++;
- }
- if(t1==0 && t2==0) s++;
- }
- return s;
- }
- void kiir()
- {
- if(a3==1 || a3 ==2)
- {
- cout<<"Nem sulyozott"<<endl;
- }
- else
- {
- cout<<"Sulyozott"<<endl;
- }
- if(a3==2 || a3==4)
- {
- cout<<"Iranyitoot"<<endl;
- }
- else
- {
- cout<<"Nem iranyitott"<<endl;
- }
- for(int i=1;i<=N;i++)
- {
- for(int j=1;j<=N;j++)
- {
- cout<<setw(3)<<A[i][j];
- }
- cout<<endl;
- }
- }
- int main()
- {
- beolvas("Graf1.txt");
- kiir();
- cout<<izolaltcs();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement