Advertisement
Anik_Akash

2 no

Oct 28th, 2020
2,320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i;
  6.     scanf("%d",&n);
  7.  
  8.     if(n<20)
  9.     {
  10.         printf("Too Small\n");
  11.     }
  12.     else
  13.     {
  14.         if(n%2==0)
  15.         {
  16.             for(i=n-1; i>0; i-=2)
  17.             {
  18.                 if(i==1)
  19.                 {
  20.                     printf("%d\n", i);
  21.                 }
  22.                 else
  23.                 {
  24.                     printf("%d-", i);
  25.                 }
  26.             }
  27.         }
  28.         else
  29.         {
  30.             for(i=n; i>0; i-=2)
  31.             {
  32.                 if(i==1)
  33.                 {
  34.                     printf("%d\n", i);
  35.                 }
  36.                 else
  37.                 {
  38.                     printf("%d-", i);
  39.                 }
  40.             }
  41.         }
  42.  
  43.  
  44.     }
  45. }
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement