fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n,temp;
  7. scanf("%d",&n);
  8. if (n==1)
  9. {
  10. int l;
  11. scanf("%d",l);
  12. printf("Yes");
  13. }
  14. else
  15. {
  16. int a,b;
  17. int last;
  18. int changes =0;
  19. int dec =0 , inc =0; //flag: checking if the set is incremental or decremental till now
  20. scanf("%d %d",&a,&b);
  21.  
  22. if (a>b)
  23. {
  24. dec=1;
  25. }
  26. else if (a<b)
  27. {
  28. inc = 1;
  29. }
  30. else
  31. {
  32. inc =1;
  33. dec = 1;
  34. }
  35. last = b;
  36. for (int i =2;i<n;i++)
  37. {
  38.  
  39. scanf("%d",&temp);
  40. if (temp>last && dec==1)
  41. {
  42. inc = 1;
  43. dec= 0;
  44. changes++;
  45. }
  46. if (temp<last && inc==1)
  47. {
  48. inc =0;
  49. dec=1;
  50. changes++;
  51. }
  52. last = temp;
  53. }
  54. if (changes <=1)
  55. {
  56.  
  57. printf("Yes");
  58. }
  59. else
  60. {
  61. printf("No");
  62. }
  63. }
  64. return 0;
  65. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5
534565463 654645645 798956554 860554521 1
compilation info
prog.c: In function ‘main’:
prog.c:11:17: error: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Werror=format=]
         scanf("%d",l);
                 ^
prog.c:11:9: error: ‘l’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         scanf("%d",l);
         ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
stdout
Standard output is empty