Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("graf.txt");
- int a[100][100];
- int main()
- {
- int i, j, m, n, x, y, d, nod, grad, izolate = 0, ok = 0, p;
- fin >> n >> m;
- for(i=1; i<=m; i++){
- fin >> x >> y;
- a[x][y] = a[y][x] = 1;
- }
- for(i=1; i<=n; i++){
- for(j=1; j<=n; j++)
- cout<<a[i][j];
- cout << endl;
- }
- cin >> nod;
- d = 0;
- for(i=1; i<=n; i++){
- if(a[i][nod] == 1){
- d++;
- cout << i << " ";
- }
- }
- cout << endl;
- for(i=1; i<=n; i++){
- grad = 0;
- for(j=1; j<=n; j++)
- if(a[i][j] == 1) grad++;
- cout<< i << " are gradul "<< grad << endl;
- if(grad == 0) izolate++;
- }
- for(i=1; i<=n && ok == 0; i++){
- grad = 0;
- for(j=1; j<=n; j++)
- if(a[i][j] == 1) grad++;
- if(grad!=n-1) ok++;
- }
- if(ok == 0) cout << "Graful este complet.\n";
- else cout << "Graful nu este complet.\n";
- cout << "Sunt " << izolate << " varfuri izolate.\n";
- cout << "Trebuie adaugate minim " << izolate << " muchii.\n";
- cin >> p;
- for(i=1; i<=p; i++)
- // ceva cod aici
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement