Guest User

Untitled

a guest
Mar 27th, 2013
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int dividers(int y,int x){
  6.  
  7. int yx;
  8. int d;
  9. int divi[100];
  10.  
  11. if(y > x){
  12. yx = y;
  13. }
  14.  
  15. if(x > y){
  16. yx = x;
  17. }
  18.  
  19. for (int n = 1; n <= yx; n++){
  20. if ((n%y==0) && (n%x==0)){
  21. d += 1;
  22. divi[d] = n;
  23. }
  24. }
  25.  
  26. return divi;
  27. }
  28.  
  29. int main()
  30. {
  31. int x,y;
  32. cout << "Enter first number: ";
  33. cin >> x;
  34. cout << endl;
  35. cout << "Enter second number: ";
  36. cin >> y;
  37. dividers(x,y); // here it should get me the divi array.(if that is somehow possible)
  38.  
  39. //here i want to paste them to the screen.
  40. for(int n = 1; n <= d; n++){
  41. cout<<divi[n] << endl;
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment