Advertisement
Marcel12311

Prosty mechanizm (tablic)

Jan 21st, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. bool CzySaTakieSame(int* tab,int* tab2,int n){
  4.     int licznik=0;
  5.     for(int i=0;i<n;i++){
  6.         if(tab[i]==tab2[i])licznik++;
  7.     }
  8.     if(licznik==10){
  9.         return true;
  10.     }else return false;
  11. }
  12. void wyswietl(int* tab,int* tab2,int n){
  13.     cout<<endl;
  14.     for(int i=0;i<n;i++){
  15.         if(tab[i]!=tab2[i]){
  16.            cout<<"["<< tab2[i]<<"] ";
  17.         }else cout << tab2[i]<<" ";
  18.    }
  19. }
  20. void wyswietl2(int* tab,int* tab2,int n){
  21.     cout<<endl;
  22.     for(int i=0;i<n;i++){
  23.         if(tab[i]!=tab2[i]){
  24.            cout<<"["<< tab[i]<<"] ";
  25.         }else cout << tab[i]<<" ";
  26.    }
  27. }
  28. int main()
  29. {
  30.     int n = 10;
  31.     int tab[n] = {0,2,3,4,5,6,7,8,9,10};
  32.     int tab2[n] = {0,2,3,4,5,6,7,8,9,10};
  33.     if(CzySaTakieSame(tab,tab2,n)==true){
  34.         cout << "tab i tab2 sa takie same:\n";
  35.         cout << "oto tablice:\n";
  36.         int i = 0;
  37.         do{
  38.             cout<<tab[i]<<" ";
  39.             i++;
  40.         }while(i<n);
  41.         cout<<endl;
  42.         i=0;
  43.         do{
  44.             cout<<tab2[i]<<" ";
  45.             i++;
  46.         }while(i<n);
  47.     }else{
  48.         cout << "tab i tab2 sa nierowne!\n";
  49.         cout << "oto tablice:\n";
  50.         wyswietl2(tab,tab2,n);
  51.         wyswietl(tab,tab2,n);
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement