Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- vector< vector< vector<char> > > funkcja(string inputdata) {
- vector< vector<char> > tab(2, vector <char>(2)); //declaration 2x2 matrix (4bytes x 4bytes)
- vector< vector< vector<char> > >tab4;
- int counter = 0;
- int k = inputdata.length(); //the length of the input data
- int division = k/4; //dividing into 4, because there are 4 char in each matrix
- int rest=k%4; //the rest from dividing into 4
- for(int t=0;t<division;t++) {
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
- tab[i][j] = inputdata[counter]; //giving input data into the matrix
- counter++;
- }
- }
- tab4.push_back(tab);
- }
- int o=k-rest+1;
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
- tab[i][j] = inputdata[o];
- o++;
- }
- }
- tab4.push_back(tab);
- return tab4;
- }
- int main()
- {
- string out= "";
- funkcja(out);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement