Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int a[1001][1001],n,m;
- ofstream out("date.out");
- void construiremat(int a[][1001],int&n,int&m,int&h)
- {
- int x,y,i,j;
- ifstream in("date.in");
- in>>n>>m;
- for(i=1; i<=m; i++)
- {
- in>>x>>y;
- a[x][y]=1;
- }
- for(i=1; i<=n; i++)
- {
- for(j=1; j<=n; j++)
- {
- a[0][i]+=a[j][i];
- a[i][0]+=a[i][j];
- }
- }
- in>>h;
- in.close();
- }
- void succesor(int x, int n)
- {
- out<<'\n';
- int i;
- out<<"succesori "<<x<<": ";
- for(i=1; i<=n; i++)
- {
- if(a[x][i]==1)
- out<<i<<" ";
- }
- }
- void predecesor(int x, int n)
- {
- out<<'\n';
- int i;
- out<<"predecesori "<<x<<": ";
- for(i=1; i<=n; i++)
- {
- if(a[i][x]==1)
- out<<i<<" ";
- }
- }
- void uplus(int x, int n)
- {
- out<<'\n';
- int i;
- out<<"Arcele care ies din "<<x<<": ";
- for(i=1; i<=n; i++)
- {
- if(a[x][i]==1)
- out<<"("<<x<<","<<i<<") ";
- }
- }
- void uminus(int x, int n)
- {
- out<<'\n';
- int i;
- out<<"Arcele care intra din "<<x<<": ";
- for(i=1; i<=n; i++)
- {
- if(a[i][x]==1)
- out<<"("<<i<<","<<x<<") ";
- }
- }
- int main()
- {
- int n,m,x,i,j;
- construiremat(a,n,m,x);
- out<<"nodurile in care gradul intern este egal cu gradul extern:";
- for(i=1; i<=n; i++)
- {
- if(a[0][i]==a[i][0])
- {
- out<<i<<" ";
- }
- }
- out<<'\n';
- succesor(x,n);
- predecesor(x,n);
- uplus(x,n);
- uminus(x,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement