fork download
  1. #include <stdio.h>
  2.  
  3. void nhapmang(int a[], int &n)
  4. {
  5. printf("nhap vao so phan tu mang : ");
  6. scanf("%d", &n);
  7. for(int i=0;i<n;i++)
  8. {
  9. printf("a[%d]= ", i);
  10. scanf("%d", &a[i]);
  11. }
  12. }
  13.  
  14. void xuatmang(int a[], int n)
  15. {
  16. printf("cac phan tu trong mang la : ");
  17. for(int i=0;i<n;i++)
  18. {
  19. printf("\na[%d]= %d",i,a[i]);
  20. }
  21. }
  22.  
  23. void xoakytu(int a[], int *n)
  24. {
  25. int x;
  26. printf("nhap vao so muon xoa: ");
  27. scanf("%d", &x);
  28. hiep:
  29. for(int i=0;i<*n;i++)
  30. {
  31. if(a[i]==x)
  32. {
  33. for(int u=i ; u<*n ; u++)
  34. {
  35. a[u]=a[u+1];
  36. }
  37. *n=*n-1;
  38. goto hiep;
  39. }
  40. }
  41. }
  42. main()
  43. {
  44. int a[100],n,x;
  45. nhapmang(a, n);
  46. xuatmang(a,n);
  47. xoakytu(a,&n);
  48. xuatmang(a,n);
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:28: error: expected ';', ',' or ')' before '&' token
 void nhapmang(int a[], int &n)
                            ^
prog.c:42:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^
prog.c: In function 'main':
prog.c:45:2: warning: implicit declaration of function 'nhapmang' [-Wimplicit-function-declaration]
  nhapmang(a, n);
  ^
prog.c:44:15: warning: unused variable 'x' [-Wunused-variable]
  int a[100],n,x;
               ^
stdout
Standard output is empty