URI Online Judge | 1070
Six Odd Numbers
Read an integer value X and print the 6 consecutive odd numbers from X, a value per line, including X if it is the case.
Input
The input will be a positive integer value.
Output
The output will be a sequence of six odd numbers.
Input Sample | Output Sample |
8 | 9 11 13 15 17 19 |
Solution:
#include <stdio.h> int main() { int X,a,b; scanf("%d", &X); if(X%2==0) { for(a=X+1;a<=X+11;a=a+2) printf("%d\n",a); } else { for(b=X;b<=X+10;b=b+2) printf("%d\n",b); } return 0; } |
Post a Comment
0Comments