fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int a[100], n, pos, value;
  6.  
  7. printf("size: ");
  8. scanf("%d", &n);
  9.  
  10.  
  11. for(int i = 0; i < n; i++)
  12. {
  13. scanf("%d", &a[i]);
  14. }
  15.  
  16.  
  17. scanf("%d", &pos);
  18.  
  19. printf("PuT nEw value: ");
  20. scanf("%d", &value);
  21.  
  22.  
  23. for(int i = n; i > pos - 1; i--)
  24. {
  25. a[i] = a[i - 1];
  26. }
  27.  
  28. a[pos - 1] = value;
  29. n++;
  30.  
  31.  
  32.  
  33. for(int i = 0; i < n; i++)
  34. {
  35. printf("%d ", a[i]);
  36. }
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0.01s 5320KB
stdin
3
23
12
43
2
11
stdout
size: PuT nEw value: 23 11 12 43