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 » Martie » 2 » program 25.02
program 25.02
12:51
#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,m;
ifstream f;


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


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

cout<<"nodul ";
cin>>l;
for(j=1;j<=m;j++)
{
if(a[l][j]==1)
k++;
}
cout<<k<<endl;


for(i=1;i<=n;i++)
{h[i]=0;
for(j=1;j<=m;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<=m;j++)
{if(a[i][j]==1)
r++;}
cout<<"sunt "<<r/2<<" muchii"<<endl;






cout<<"muchiile sunt: "<<endl;
for(j=1;j<=m;j++)

{cout<<"muchia "<<j<<endl;
for(i=1;i<=n;i++)
{if(a[i][j]==1)
cout<<i<<" ";}
cout<<endl;}



cout<<"vecinii nodului:"<<endl;;
cin>>nod;
cout<<"sunt: "<<endl;

for(int k=1;k<=m;k++)
if(a[nod][k]==1)
for(i=1;i<=n;i++)
if(i!=nod && a[i][k]==1)
cout<<i<<" ";
cout<<endl;
cout<<"nodurile cu gradul cel mai mare sunt:"<<endl;



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<<i<<" ";}}
cout<<endl<<"numarul de noduri cu gradul cel mai mare este "<<o<<" avand gradul "<<max;



int t=0;
for(j=1;j<=m;j++)
{for(i=1;i<=n;i++)
if(a[i][j]==0 || a[i][j]==1)
if(a[i][j]==1)
t++;}
if(t==2*m)
cout<<endl<<"este matricea unu graf neorientat";
else 
cout<<endl<<"nu este matricea unu graf neorientat";
return 0;
 }
Views: 463 | Added by: Iulian
Only registered users can add comments.
[ Registration | Login ]
Logheaza-te
Calendar
«  Martie 2011  »
DuLuMaMiJoViSa
  12345
6789101112
13141516171819
20212223242526
2728293031
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