Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int& TV(int* p, int lim1, int lim2, int lim3, int f, int n){
- return *(p + n * lim3 + f);
- }
- int main()
- {
- int x[100];
- for(int i=0; i<100; i++){
- cin >> x[i];
- }
- int lim1, lim2, lim3;
- int arr[4];
- cin >> lim1 >> lim2 >> lim3;
- cout<<"start"<<endl;
- // ciclo che invoca TV da fare
- int w = 0;
- int* p = x;
- int r = 0;
- int aux;
- while(r != -1){
- cin>>r;
- if(r != -1){
- arr[w] = r;
- w++;
- }
- if(w == 4){
- int & el = TV(p, lim1, lim2, lim3, arr[0], arr[1]);
- int & el2 = TV(p, lim1, lim2, lim3, arr[2], arr[3]);
- aux = el;
- el = el2;
- el2 = aux;
- }
- if(w == 4){
- w = w - 4;
- }
- }
- w = 0;
- for(int i = 0; i < lim1; i++){
- for(int j = 0; j < lim2; j++){
- for(int k = 0; k < lim3; k++){
- cout<<x[w]<<" ";
- w++;
- }
- cout<<endl;
- }
- cout<<endl;
- }
- cout<<"end";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement