fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <conio.h>
  5. #include <cmath>
  6.  
  7. void NhapMang(int a[], int n)
  8. {
  9. for(int i = 0; i < n; ++i)
  10. {
  11. cout << "a[" << i << "] = ";
  12. cin >> a[i];
  13. }
  14. }
  15.  
  16. void XuatMang(int a[], int n)
  17. {
  18. for(int i = 0; i < n; ++i)
  19. {
  20. cout << a[i] << " ";
  21. }
  22. }
  23.  
  24. void ChenMang(int a[], int &n, int VTChen, int PTChen)
  25. {
  26. ++n;
  27. for(int i = n - 1; i >= VTChen; --i)
  28. {
  29. a[i] = a[i - 1];
  30. }
  31. a[VTChen] = PTChen;
  32. }
  33.  
  34. int main()
  35. {
  36. BatDau:
  37.  
  38. int n;
  39. cout << "\nNhap n: "; cin >> n;
  40.  
  41. int a[100];
  42.  
  43. cout << "\nNhap mang cua ban:\n";
  44. NhapMang(a, n);
  45. cout << "\nXuat mang cua ban:\n";
  46. XuatMang(a, n);
  47.  
  48. int VTChen, PTChen;
  49. cout << "\nNhap VTChen & PTChen: "; cin >> VTChen >> PTChen;
  50. ChenMang(a, n, VTChen, PTChen); // co the Chen vao vi tri i = [0, n];
  51. cout << "\nMang sau khi chen:\n";
  52. XuatMang(a, n);
  53.  
  54. cout << "\nNhap y de kiem tra lai:";
  55. char y = getch();
  56. if(y == 'Y' || y == 'y')
  57. {
  58. system("cls");
  59. goto BatDau;
  60. }
  61.  
  62. system("pause");
  63. return 0;
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
stdout
Standard output is empty