Bun venit Guest | RSS
Bine ati venit la 9C acasa
Meniul Site-ului
Horoscop
Exprima-ti opinia
Ce parere aveti despre site?
1. Foarte buna
2. Foarte proasta
3. Buna
4. Normal
5. Proasta
[ Vezi rezutat ยท Arhiva ]
Raspunsuri: 42
Mini chat

Info


Main » 2011 » Februarie » 9 » program 11 subpuncte
program 11 subpuncte
13:21
#include<iostream.h>
#include<fstream.h>

int i,n,j,a[10][10],k=0,l,h[10],p=0,p1=0,r=0,nod;
ifstream f;

void afisare(int a[10][10], int n)
{for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;}}

int main()
{f.open("date");
f>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
f>>a[i][j];
f.close();
afisare(a,n);
cout<<"nodul ";
cin>>l;
for(j=1;j<=n;j++)
{
if(a[l][j]==1)
k++;
}
cout<<k<<endl;

for(i=1;i<=n;i++)
{h[i]=0;
for(j=1;j<=n;j++)
{
if(a[i][j]==1)
h[i]++;
}}
for(i=1;i<=n;i++)
cout<<"gradul pentru nodul "<<i<<" este "<<h[i]<<endl;

for(i=1;i<=n;i++)
if(h[i]==0)
{p++;
cout<<"nodul "<<i<<" este izolat"<<endl;
}
if(p>0)
cout<<"sunt "<<p<<" noduri izolate"<<endl;
else
cout<<"nu avem mnoduri izolate;"<<endl;
for(i=1;i<=n;i++)
if(h[i]==1)
{p1++;
}
if(p1>0)
cout<<"sunt "<<p1<<" noduri terminale"<<endl;
else
cout<<"nu sunt noduri terminale"<<endl;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{if(a[i][j]==1)
r++;}
cout<<"sunt "<<r/2<<" muchii"<<endl;
cout<<"muchiile sunt: "<<endl;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{if(a[i][j]==1)
cout<<"muchia "<<i<<" si "<<j<<endl;}
cout<<"vecinii nodului:"<<endl;;
cin>>nod;
cout<<"sunt: ";
for(i=1;i<=n;i++)
if(a[nod][i]==1)
cout<<i<<" ";
int max=h[1];
for(i=2;i<=n;i++)
if(max<h[i])
max=h[i];
int o=0;
for(i=1;i<=n;i++)
{if(h[i]==max)
o++;}
cout<<endl<<"numarul de noduri cu gradul cel mai mare este "<<o<<" avand gradul "<<max;
int t=0;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(a[i][j]==0 || a[i][j]==1)
if(a[i][j]==1 && a[j][i]==1)
t++;
if(t==2*n)
cout<<endl<<"este matricea unu graf neorientat";
else 
cout<<endl<<"nu este matricea unu graf neorientat";
return 0;
 }

date
7
0 1 1 0 0 0 0
1 0 0 0 1 0 0
1 0 0 1 1 0 0
0 0 1 0 1 0 1
0 1 1 1 0 0 0
0 0 0 0 0 0 0
0 0 0 1 0 0 0
Views: 575 | Added by: Iulian
Only registered users can add comments.
[ Registration | Login ]
Logheaza-te
Calendar
«  Februarie 2011  »
DuLuMaMiJoViSa
  12345
6789101112
13141516171819
20212223242526
2728
Meteo
Curs Valutar
Curs Valutar BNR
Cautare
Link-uri
Statistica
Director web gratuit - Afisare Thumbnail, Transfer Google PageRank, Meta keywords si meta description personalizate pentru fiecare link Site clasei 9C Colegiul National Mihai Eminescu, Muzica Stiri Sport, Filme Top66 Statistici
Total online: 1
Guests: 1
Users: 0