Advertisement
Guest User

Untitled

a guest
Oct 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <math.h>
  4. #include "stdio.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10. typedef std::vector<double> Vec;
  11. typedef std::vector<std::vector<double> > Mat;
  12.  
  13. void printVec(Vec a) {
  14.     for(int i = 0; i < a.size(); i++) {
  15.         printf("%0.lf ", a[i]);
  16.     }
  17. }
  18. void printMat(Mat A) {
  19.     for(int i = 0; i < A.size(); i++) {
  20.         for(int j = 0; j < A[0].size(); j++) {
  21.             printf("%0.lf ", A[i][j]);
  22.         }
  23.         printf("\n");
  24.     }
  25. }
  26. Vec szindroma_szamolasa(Mat A, Vec x) {
  27.     Vec szindroma;
  28.     int sum = 0;
  29.  
  30.     for(int i = 0; i < A.size(); i++) {
  31.         for(int j = 0; j < A[0].size(); j++) {
  32.             sum+= A[i][j] * x[j];
  33.             sum = sum % 3;
  34.         }
  35.         szindroma.push_back(sum);
  36.         sum = 0;
  37.     }
  38.     return szindroma;
  39. }
  40. int main()
  41. {
  42.     Mat A;
  43.     double q;
  44.     Vec x;
  45.     //Beolvasas
  46.     for(int i = 0; i < 5; i++){
  47.         for(int j = 0; j < 11; j++) {
  48.             scanf("%lf", &q);
  49.             x.push_back(q);
  50.         }
  51.         A.push_back(x);
  52.         x.clear();
  53.     }
  54.     printf("\n");
  55.  
  56.  
  57.     for(int l = 1; l<5; l++) {
  58.         int a = -1;
  59.         for(int k = 0; k<11; k++) {
  60.             for(int i = 0+k; i<11; i++) {
  61.                 for(int j = 0; j<11; j++) {
  62.                     if(i==j && l < 3)
  63.                         x.push_back(l);
  64.                     else if (a == j && l<3)
  65.                         x.push_back(l);
  66.  
  67.                     else if(i==j && l == 3)
  68.                         x.push_back(2);
  69.                     else if (a == j && l==3)
  70.                         x.push_back(1);
  71.  
  72.                     else if(i==j && l == 4)
  73.                         x.push_back(1);
  74.                     else if (a == j && l==4)
  75.                         x.push_back(2);
  76.  
  77.                     else
  78.                         x.push_back(0);
  79.                 }
  80.  
  81.                 printVec(x);
  82.                 printf("\n");
  83.                 Vec sz = szindroma_szamolasa(A, x);
  84.                 x.clear();
  85.                 printVec(sz);
  86.                 printf("\n");
  87.  
  88.             }
  89.             a++;
  90.         printf("\n\n");
  91.         }
  92.     }
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement