03-language introduction -03-odd even separation

Source: Internet
Author: User

Title Address: http://acm.nyist.net/JudgeOnline/problem.php?pid=11 Description
There is an integer even n (2<= n <=10000), you have to do is: first 1 to N of all the odd numbers from small to large output, and then all the even from small to large output. Input
The first line has an integer I (2<=i<30) that indicates that I have a set of test data;
Each group has an integral type even n. Output
The first line outputs all the odd numbers
The second line outputs all the even sample inputs
2
10
14
Sample output
1 3 5) 7 9
2 4 6) 8 10

1 3 5 7 9 11 13
2 4 6 8 10 12 14 Code:

#include <stdio.h>

int main ()
{
int readlen = 0;
scanf ("%d", &readlen);
GetChar ();
    
While (Readlen > 0)
     {
int num =-1;
scanf ("%d", &num);
GetChar ();
         
if (num% 2 = 0)
continue;
              
int i=1;
For (; i<num;i+=2)
          {
printf ("%d", I);
          }
printf ("\ n");
         
i=2;
For (; i<=num;i+=2)
          {
printf ("%d", I);
          }
printf ("\ n");
         
--readlen;
     }
    
return 0;

}

03-language introduction -03-odd even separation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.