Advertisement
Guest User

Untitled

a guest
Jul 6th, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int dimA = 7;
  6. const int dimB = 2;
  7. const int dimC = 2;
  8.  
  9. int divisione(int a[dimA], int b[dimB])
  10. {
  11.         for(int i = 0; i <= dimA; i++)
  12.         {
  13.                 for(int j = 0; j <= dimB; j++)
  14.                 {
  15.  
  16.                         if(a[i] % b[j] != 0 && a[i] % b[j+1] != 0)
  17.                         {
  18.                                 cout << a[i] <<"\n";
  19.  
  20.                         }
  21.         }       }
  22.  
  23. return 0;
  24.  
  25. }
  26.  
  27. int main()
  28. {
  29.         int a[dimA] = {2,45,37,21,6,34,35};
  30.         int b[dimB] = {2,3};
  31.  
  32. divisione(a,b);
  33.  
  34. return 0;
  35. }
  36.  
  37. -----------------------------------------------------------------
  38. L'OUTPUT È:
  39. -----------------------------------------------------------------
  40.  
  41. 37
  42. 37
  43. 37
  44. 21
  45. 35
  46. 35
  47. 35
  48.  
  49. Perchè stampa anche 21?? E perchè ripete i numeri?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement