Advertisement
pVinc

noweporownanie.cpp

Oct 22nd, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool zawiera(int tab[], int rozmiartablicy, int wymaganaliczba){
  6. int i = 0;
  7. for(i; i <= rozmiartablicy-1; i++){
  8. if(tab[i] == wymaganaliczba){ return true; }
  9. }
  10. return false;
  11. }
  12.  
  13. bool sa_rowne(int tab[], int tab2[], int rozmiar1, int rozmiar2){
  14. if(rozmiar1 != rozmiar2){ return false; }
  15. int i = 0, k = 0;
  16. bool j = 0;
  17. for(i; i<=rozmiar1; i++){
  18. j = zawiera(tab2, rozmiar2, tab[i]);
  19. if(j){ k++; }
  20. }
  21. if(k == rozmiar1){
  22. return true;
  23. } else {
  24. return false;
  25. }
  26. }
  27.  
  28. int main(){
  29. int x, c=0, tab[10], i=0, k=0, a=0;
  30. int y, d=0, tab2[10], j=0, l=0, b=0;
  31.  
  32. for(k; k <= 9; k++){
  33. tab[k] = 0;
  34. tab2[k] = 0;
  35. }
  36.  
  37. cout << "Podaj liczby" << endl;
  38. cin >> x;
  39. cin >> y;
  40.  
  41. while(x > 0){
  42. a = x%10;
  43. tab[c] = a;
  44. x /= 10;
  45. c++;
  46. }
  47.  
  48. while(y > 0){
  49. b = y%10;
  50. tab2[d] = b;
  51. y /= 10;
  52. d++;
  53. }
  54.  
  55. for(i; i <= c-1; i++){
  56. cout << tab[i] << endl;
  57. }
  58.  
  59. for(j; j <= d-1; j++){
  60. cout << tab2[j] << endl;
  61. }
  62.  
  63. bool m = sa_rowne(tab, tab2, c-1, d-1);
  64. if(m){
  65. cout << "Rowne" << endl;
  66. }else{
  67. cout << "Nierowne" << endl;
  68. }
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement