SHARE
TWEET

Untitled

a guest May 25th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. vector< vector< vector<char> > > funkcja(string inputdata) {
  8.     vector< vector<char> > tab(2, vector <char>(2)); //declaration 2x2 matrix (4bytes x 4bytes)
  9.     vector< vector< vector<char> > >tab4;
  10.  
  11.     int counter = 0;
  12.     int k = inputdata.length(); //the length of the input data
  13.     int division = k/4; //dividing into 4, because there are 4 char in each matrix
  14.     int rest=k%4; //the rest from dividing into 4
  15.  
  16.     for(int t=0;t<division;t++) {
  17.         for (int i = 0; i < 2; i++) {
  18.             for (int j = 0; j < 2; j++) {
  19.                 tab[i][j] = inputdata[counter]; //giving input data into the matrix
  20.                 counter++;
  21.             }
  22.         }
  23.         tab4.push_back(tab);
  24.     }
  25.     int o=k-rest+1;
  26.     for (int i = 0; i < 2; i++) {
  27.             for (int j = 0; j < 2; j++) {
  28.                 tab[i][j] = inputdata[o];
  29.                 o++;
  30.             }
  31.         }
  32.     tab4.push_back(tab);
  33.  
  34. return tab4;
  35. }
  36.  
  37. int main()
  38. {
  39.     string out= "";
  40.     funkcja(out);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top