fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <malloc.h>
  5. #include <stdlib.h>
  6. void swap(int *a, int *b);
  7. int o1 = -1;
  8. int o2 = -1;
  9. int n, j;
  10. int i;
  11.  
  12.  
  13. void main()
  14. {
  15. printf("Input n: ");
  16. scanf_s("%d", &n);
  17. int* a;
  18. a = (int *)malloc(n * sizeof(int));
  19. printf("Input the array elements:\n");
  20. for(i = 0; i < n; i++)
  21. scanf_s("%d", a+i);
  22. for(i = 0; (i < n)||(o1==-1); i++)
  23. {
  24. if (a[i] < 0)
  25. {
  26. o1 = i;
  27. }
  28. }
  29. if (o1 == -1)
  30. printf("oshibka net otricatelnih/n");
  31.  
  32. for(i = o1+1; (i < o2)||(o2==-1); i++)
  33. {
  34. if (a[i] < 0)
  35. {
  36. o2 = i;
  37. }
  38. }
  39. if (o2 == -1)
  40. printf("oshibka net vtorogo otricatelnogo\n");
  41. for(i = o1+1; i < o2-1; i++)
  42. for(j = i + 1; j < o2; j++)
  43. if(a[j] < a[i])
  44. swap(a+i, a+j);
  45. _getch();
  46. }
  47.  
  48. void swap(int *a, int *b)
  49. {
  50. int t; t = *a, *a = *b, *b = t;
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:19: fatal error: conio.h: No such file or directory
 #include <conio.h>
                   ^
compilation terminated.
stdout
Standard output is empty