Wednesday, December 2, 2015

Uri problem 1070 solve

Problem :

Six Odd Numbers

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer value and print the 6 consecutive odd numbers from X, a value per line, including 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.
Sample InputSample Output
89
11
13
15
17
19

Solution:


#include<cstdio>
 
int main()
{
    int X , i;
    scanf("%d",&X);
    if(X % 2 != 0){
        for(i = X; i < X + (2*6); i++){
            if(i % 2 != 0)
                printf("%d\n",i);
        }
    }
    else{
         for(i = X; i < X + (2*6)+1; i++){
            if(i % 2 != 0)
                printf("%d\n",i);
         }
    }
 
 
    return 0;
}

No comments:

Post a Comment