Advertisement
Guest User

asdasdawdfqwrq22222222224242424241edqwd

a guest
Dec 12th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv) {
  8.  
  9. /*napisz program ktory utworzy 2 tab kwadratowe
  10. dynamiczne o rozmiarze
  11. podanym przez uzytkownika wypelnij je l. los. z przedzialu
  12. od 1 do 9 a nastepnie wyswietl info o liczbie el. ktore
  13. stoja na tych samych pozycjach
  14. w obu tab i maja te same wartosci*/
  15.  
  16. int a;
  17. int s=0;
  18. cout<<"podaj liczbe ";
  19. cin>>a;
  20.  
  21. int w=a;
  22. int k=a;
  23.  
  24.  
  25. int **ws;
  26. int **ws2;
  27.  
  28. ws = new int*[w];
  29. ws2 = new int*[w];
  30.  
  31. srand(time(NULL));
  32.  
  33.  
  34. for(int i=0 ; i<w ; i++)
  35. {
  36. ws[i] = new int[k];
  37. ws2[i] = new int[k];
  38. }
  39.  
  40. for(int i=0 ; i<w ; i++)
  41. {
  42. for(int j=0 ; j<k ; j++)
  43. {
  44. ws[i][j] = rand()%9+1;
  45. ws2[i][j] = rand()%9+1;
  46. if(ws[i][j] == ws2[i][j])
  47. {
  48. s++;
  49. }
  50. }
  51. }
  52.  
  53. for(int i=0 ; i<w ; i++)
  54. {
  55. for(int j=0 ; j<k ; j++)
  56. {
  57. cout<<ws[i][j]<<" ";
  58. }
  59. cout<<endl;
  60. }
  61.  
  62. cout<<endl;
  63. cout<<endl;
  64.  
  65. for(int i=0 ; i<w ; i++)
  66. {
  67. for(int j=0 ; j<k ; j++)
  68. {
  69. cout<<ws2[i][j]<<" ";
  70. }
  71. cout<<endl;
  72. }
  73.  
  74. cout<<endl;
  75. cout<<"liczba powtorzen "<<s;
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement