Jump to content

Recommended Posts

Posted

1. Graf_partial

Sa se scrie un program care citeste de la tastatura o matrice de adiacenta asociata grafurilor g si g`,cu cate n noduri fiecare si verifica daca g` este partial pentru g.

#include<iostream.h>

int a[20][20], b[20][20],n;

void citire(int x[20][20]){

for (int i=1;i<=n;i++)

for (int j=1;j<=n;j++)

{cout<<"a["<<i<<"]["<<j<<"]=";

cin>>x[i][j];}}

int partial()

{for (int i=1;i<=n;i++)

for (int j=1;j<=n;j++)

if((b[i][j]==i)&&(a[i][j]==0)) return 0;

return 1;}

void main()

{cout<<"n=";cin>>n;

citire(a);citire(b);

if(partial())

cout<<"graful g` este partial pentru g";

else cout<<"nu este";}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.