0% found this document useful (0 votes)
33 views2 pages

1 Feladat

The document contains code for two programming tasks. The first task reads in data and stores it in a 2D boolean array to represent a matrix. The second task reads in data to represent a directed graph and stores the graph edges in a 2D integer array, then converts it to a 2D boolean array representation for output.

Uploaded by

Balog Emese
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

1 Feladat

The document contains code for two programming tasks. The first task reads in data and stores it in a 2D boolean array to represent a matrix. The second task reads in data to represent a directed graph and stores the graph edges in a 2D integer array, then converts it to a 2D boolean array representation for output.

Uploaded by

Balog Emese
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

feladat:

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
ifstream fin("valami.in");
int n,m,xs;
char x;
fin>>n>>m;
bool t[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
t[i][j]=0;
}
for(int y=0;y<m;y++){
fin>>xs;
t[xs-1][y]=1;
fin>>x;
fin>>xs;
t[xs-1][y]=1;
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
cout<<t[i][j]<<' ';
cout<<endl;
}

}
2.feladat:

#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

//! iranyitott graf!

int main()
{
ifstream fin("valami.in");
int n,i,j,m=1;
fin>>n;
int t[n][n];
for(i=0;i<n;i++)
for(j=0;j<n;j++){
fin>>t[i][j];
if(t[i][j]==1) t[i][j]=m++;
}
/*
for(i=0;i<n;i++){
for(j=0;j<n;j++)
cout<<t[i][j]<<' ';
cout<<endl;
}
cout<<endl<<endl;
//*/
bool h[n][m];
for(i=0;i<n;i++)
for(j=0;j<m;j++)
h[i][j]=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(t[i][j]!=0){
h[i][t[i][j]-1]=1;
h[j][t[i][j]-1]=1;
}
for(i=0;i<n;i++){
for(j=0;j<m;j++)
cout<<h[i][j]<<' ';
cout<<endl;
}

You might also like