Advertisement
huutho_96

Untitled

Mar 24th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <malloc.h>
  4.  
  5. int *nhapmang(int &n)
  6. {
  7. int *a;
  8. printf("Nhap so luong phan tu trong mang: ");
  9. scanf("%d", &n);
  10. a = new int[n];
  11. for (int i = 0; i < n; i++)
  12. {
  13. printf("Nhap ptu %d: ", i + 1);
  14. scanf("%d", &a[i]);
  15. }
  16. return a;
  17. }
  18. void xuatmang(int *a, int n)
  19. {
  20. for (int i = 0; i < n; i++)
  21. {
  22. printf("Phan tu %d: %d\n", i + 1, a[i]);
  23. }
  24. }
  25. void main()
  26. {
  27. int *a = NULL;
  28. int n;
  29. a = nhapmang(n);
  30. xuatmang(a, n);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement