Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int main(int argc, char** argv) {
- /*napisz program ktory utworzy 2 tab kwadratowe
- dynamiczne o rozmiarze
- podanym przez uzytkownika wypelnij je l. los. z przedzialu
- od 1 do 9 a nastepnie wyswietl info o liczbie el. ktore
- stoja na tych samych pozycjach
- w obu tab i maja te same wartosci*/
- int a;
- int s=0;
- cout<<"podaj liczbe ";
- cin>>a;
- int w=a;
- int k=a;
- int **ws;
- int **ws2;
- ws = new int*[w];
- ws2 = new int*[w];
- srand(time(NULL));
- for(int i=0 ; i<w ; i++)
- {
- ws[i] = new int[k];
- ws2[i] = new int[k];
- }
- for(int i=0 ; i<w ; i++)
- {
- for(int j=0 ; j<k ; j++)
- {
- ws[i][j] = rand()%9+1;
- ws2[i][j] = rand()%9+1;
- if(ws[i][j] == ws2[i][j])
- {
- s++;
- }
- }
- }
- for(int i=0 ; i<w ; i++)
- {
- for(int j=0 ; j<k ; j++)
- {
- cout<<ws[i][j]<<" ";
- }
- cout<<endl;
- }
- cout<<endl;
- cout<<endl;
- for(int i=0 ; i<w ; i++)
- {
- for(int j=0 ; j<k ; j++)
- {
- cout<<ws2[i][j]<<" ";
- }
- cout<<endl;
- }
- cout<<endl;
- cout<<"liczba powtorzen "<<s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement