Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #define MN 31
- using namespace std;
- int N=0; //csucsok szama
- double A[MN][MN]; //csucsmatrix
- void init(){
- for(int i=1; i<MN; i++){
- for(int j=1; j<MN; j++){
- A[i][j]=0;
- }
- }
- }
- void beolvas(char *fnev){
- ifstream f;
- f.open(fnev);
- int a1, a2, a3;
- 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;
- }
- /** _____
- /\ \ \ \ \
- /OO\ \____\ \___ \
- /____\ \ \ \ \
- \ \ \_____ \_____
- **/
- case 2:{ //szomszedsagi lista
- if(a3>=3)break;
- for(int n=1; n<=N; n++){
- int cs, szn, sz;
- f>>cs>>szn;
- for(int i=1; i<=szn; i++){
- f>>sz;
- A[cs][sz]=1;
- }
- }
- break;
- }
- case 3:{
- int esz;
- f>>
- break;
- }
- }
- }
- void kiir(){
- for(int i=1; i<=N; i++){
- for(int j=1; j<=N; j++){
- cout<<A[i][j]<<" ";
- }
- cout<<"\n";
- }
- }
- int main()
- {
- init();
- beolvas("graf2.txt");
- kiir();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement