Advertisement
mashlukashova

Untitled

Mar 7th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. //не работает
  2.  
  3.  
  4. #include<cmath>
  5. #include <iostream>
  6. #include <cstdlib>
  7. #include <vector>
  8. using namespace std;
  9. int main() {
  10.     setlocale(LC_ALL, "rus");
  11.     int n, dop, v = 1, el_dop = 0, temp, sum = 0;
  12.     char el;
  13.     vector<char>m;
  14.     std::cout << "введите n: " <<endl;
  15.     cin >> n;
  16.     char a[n][n];
  17.    
  18.    
  19.     cout << "введите двумерный массив: " << endl;
  20.     for (int i = 0; i < n; i++){
  21.         for (int j = 0; j < n; j++){
  22.             cin >> a[i][j];
  23.         }
  24.     }
  25.    
  26.     for (int j = 0; j < n; j++){
  27.         for (int i = 1; i < n; i++){
  28.            
  29.             if (i + j >= n){
  30.                 temp = (int)a[i][j];
  31.                 sum += temp;
  32.                
  33.                 for (int d = 1; d < sum + 1; d++){
  34.                     if (sum % d == 0) v++;
  35.                 }
  36.                     if (v == 2) el_dop = sum%127;
  37.                     else if (v > 2) el_dop = sum%126;
  38.                
  39.                     el = (char)el_dop;
  40.                
  41.                     m.push_back(el);
  42.                     break;
  43.                         }
  44.            
  45.         }
  46.     }
  47.    
  48.    
  49.     cout << "ответ: " << endl;
  50.     for(int i = 0; i < n; i++){
  51.         cout << m[i] << " ";
  52.     }
  53.    
  54.    
  55.     cout << endl;
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement