Advertisement
hurmawe

Подсчет количества ребер неориентированного графа

Dec 18th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int32_t     lenght;
  7.     int32_t     counter =0;
  8.     cin >> lenght;
  9.     vector<vector<int8_t>>  array(lenght);
  10.     for(int i =0; i < lenght; i++) {
  11.         array[i].resize(lenght);
  12.         for (int j = 0; j < lenght; ++j) {
  13.             cin >> array[i][j];
  14.         }
  15.     }
  16.     int j = 1;
  17.     for(int i=0;i <lenght-1;i++)
  18.     {
  19.  
  20.         for(;j<lenght;j++)
  21.         {
  22.             if(array[i][j] == '1')
  23.             {
  24.                 counter++;
  25.             }
  26.         }
  27.         j=i+1;
  28.     }
  29.  
  30.     cout << counter;
  31.  
  32.  
  33.     return  0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement