Advertisement
Guest User

musty

a guest
Apr 1st, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. //#include <testing.h>
  3. int main(void) {
  4. int M;
  5. int A[20];
  6. int temp;
  7. int j=0;
  8. scanf("%d\n", &M);
  9. if (M > 20 || M < 2)
  10. {
  11. //WAIT_ANY_KEY
  12. return 0;
  13. }
  14. for (int i=0; i<M; i++)
  15. {
  16. scanf("%d", &temp);
  17. if (temp <= 1000 && temp >= -1000)
  18. {
  19. if(((temp > A[j-1])) && (i > 0))
  20. {
  21. A[j]=temp;
  22. j++;
  23.  
  24. }
  25. else
  26. {
  27. if(i==0)
  28. {
  29. A[i]=temp;
  30. j++;
  31. }
  32. }
  33.  
  34. }
  35. else
  36. {
  37. // WAIT_ANY_KEY
  38. return 0;
  39. }
  40. }
  41. for (int k = 0; k < j; k++)
  42. {
  43. for(int z=0; z<=k; z++)
  44. {
  45. printf("%d ",A[z]);
  46. }
  47.  
  48. printf("\n");
  49. }
  50.  
  51. //WAIT_ANY_KEY
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement