Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- #include "stdio.h"
- #include <iostream>
- #include <string>
- #include <algorithm>
- using namespace std;
- typedef std::vector<double> Vec;
- typedef std::vector<std::vector<double> > Mat;
- void printVec(Vec a) {
- for(int i = 0; i < a.size(); i++) {
- printf("%0.lf ", a[i]);
- }
- }
- void printMat(Mat A) {
- for(int i = 0; i < A.size(); i++) {
- for(int j = 0; j < A[0].size(); j++) {
- printf("%0.lf ", A[i][j]);
- }
- printf("\n");
- }
- }
- Vec szindroma_szamolasa(Mat A, Vec x) {
- Vec szindroma;
- int sum = 0;
- for(int i = 0; i < A.size(); i++) {
- for(int j = 0; j < A[0].size(); j++) {
- sum+= A[i][j] * x[j];
- sum = sum % 3;
- }
- szindroma.push_back(sum);
- sum = 0;
- }
- return szindroma;
- }
- int main()
- {
- Mat A;
- double q;
- Vec x;
- //Beolvasas
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 11; j++) {
- scanf("%lf", &q);
- x.push_back(q);
- }
- A.push_back(x);
- x.clear();
- }
- printf("\n");
- for(int l = 1; l<5; l++) {
- int a = -1;
- for(int k = 0; k<11; k++) {
- for(int i = 0+k; i<11; i++) {
- for(int j = 0; j<11; j++) {
- if(i==j && l < 3)
- x.push_back(l);
- else if (a == j && l<3)
- x.push_back(l);
- else if(i==j && l == 3)
- x.push_back(2);
- else if (a == j && l==3)
- x.push_back(1);
- else if(i==j && l == 4)
- x.push_back(1);
- else if (a == j && l==4)
- x.push_back(2);
- else
- x.push_back(0);
- }
- printVec(x);
- printf("\n");
- Vec sz = szindroma_szamolasa(A, x);
- x.clear();
- printVec(sz);
- printf("\n");
- }
- a++;
- printf("\n\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement