Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. char screen[25][80];
  6. int** array = NULL;
  7. int amount = 0;
  8.  
  9. int search(int inputNumber);
  10.  
  11. void window(int numaber);
  12.  
  13. int main(){
  14.     for(int i = 0; i < 25; ++i){
  15.         for(int j = 0; j < 80; ++j){
  16.             screen[i][j] = '.';
  17.         }
  18.     }
  19.  
  20.     cin >> amount;
  21.  
  22.     array = new int*[amount];  // инициализация работает
  23.     for(int i = 0; i < amount; ++i){
  24.         array[i] = new int[6];
  25.         for(int j = 0; j < 6; ++j){
  26.             array[i][j] = 0;
  27.         }
  28.     }
  29.  
  30.     cout << "Initiationg array assignment" << endl;
  31.  
  32.     for(int i = 0; i < amount; ++i){  //считывание работает
  33.         int lim = 6;
  34.         cin >> array[i][0];
  35.         if(array[i][0] == 0){
  36.             lim = 2;
  37.         }
  38.         for(int j = 1; j < lim; ++j){
  39.             cin >> array[i][j];
  40.         }
  41.     }
  42.    
  43.     cout << "initiating screen assignment" << endl;
  44.  
  45.     for(int i = 0; i < amount; ++i){ //не работает
  46.         if(array[i][0] != 0){
  47.             cout << "Initiating function window" << endl;  
  48.             window(i); 
  49.         }
  50.         else{
  51.             cout << "Initiating function search. ";
  52.             int k = search(array[i][1]);
  53.             cout << "Initiating function window" << endl;
  54.             window(k);
  55.         }
  56.     }
  57.  
  58.     cout << "Initiating screen displaying" << endl;
  59.  
  60.     for(int i = 0; i < 25; ++i){ //вывод работает
  61.         for(int j = 0; j < 80; ++j){
  62.             cout << screen[i][j];
  63.         }
  64.         cout << endl;
  65.     }  
  66.  
  67.     /*cout <<"Initiating array displaying" << endl;
  68.  
  69.     for(int i = 0; i < amount; ++i){ //тестовый вывод считанного массива, работает
  70.         int lim = 6;
  71.         if(array[i][0] == 0){
  72.             lim = 2;   
  73.         }
  74.         for(int j = 0; j < lim; ++j){
  75.             cout << array[i][j] << ' ';
  76.         }
  77.         cout << endl;
  78.     }*/
  79.     delete array;
  80.     return 0;
  81. }
  82.  
  83. int search(int inputNumber){ //функция работает
  84.     int i = 0;
  85.     while(array[i][0] != inputNumber){
  86.         ++i;
  87.     }
  88.  
  89.     return i;
  90. }
  91.  
  92. void window(int num){ //функция работает
  93.     for(int i = array[num][1] - 1; i < array[num][3]; ++i){
  94.         for(int j = array[num][2] - 1; j < array[num][4]; ++j){
  95.             screen[i][j] = array[num][5];
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement