Advertisement
gosuodin

bai tap 4

Jun 20th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int nhapmang(int *a, int n) {
  4. for (int i = 0; i < n; i++) {
  5. cout << " nhap a[ " << i << "]";
  6. cin >> *(a + i);
  7. }
  8. return 0;
  9. }
  10. int suat(int *a,int n) {
  11. int k = 0;
  12. for(int i =0;i<n;i++){
  13. for (int j = 0; j < n; j++) {
  14. if ((*(a + i) % *(a + j) == 0)&&(j!=i)&&(k==0)) {
  15. k = 1;
  16. cout << *(a +i);
  17. }
  18. }
  19. }
  20. return 0;
  21.  
  22. }
  23.  
  24. void main() {
  25. int n;
  26. cout << "nhap n :";
  27. cin >> n;
  28. int a[5] = { 4, 6, 7, 8,12 };
  29. suat(a, 5);
  30.  
  31. system("pause");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement