Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[100][100],v[100],n;
- int k;
- void citire_graf(){
- int m,x,y;
- cout<<"nr muchii: ";cin>>m;
- for(int i=1;i<=m;i++){
- cout<<"muchie:";cin>>x>>y;
- a[x][y]=a[y][x]=1;
- }
- }
- void afisare(int n){
- for(int i=1;i<=n;i++)
- {for(int j=1;j<=n;j++)
- cout<<a[i][j]<<" ";
- cout<<"\n";
- }
- }
- void citire_secventa(){
- cout<<"nr elem: ";cin>>k;
- for(int i=1;i<=k;i++)
- cin>>v[i];
- }
- bool eLant(){
- for(int i=1;i<k;i++)
- if(a[v[i]][v[i+1]]==0)
- return false;
- return true;
- }
- bool elemetrar(){
- if(eLant()){
- for(int i=1;i<=n;i++)
- for(int j=i+1;j<=n;j++)
- if(v[i]==v[j])
- return false;
- return true;
- }
- return false;
- }
- int main()
- {cout<<"noduri: ";cin>>n;
- citire_graf();
- afisare(n);
- citire_secventa();
- if(elemetrar())
- cout<<"da";
- else
- cout<<"nu";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement