Onge C Language Introduction third week programming problem (revision) of "sub-queue"

Source: Internet
Author: User

Topic content:

Class for the first time, usually the teacher will let students in a row by height, and then 1, 2 count, shout to 1 of the students forward a step, so that the team becomes two columns. Suppose now a class has n students, and they have been ranked by height in a row, students by height from 1 to n number, you can tell me the last number of students standing in the first column?

Input format:

Enter a positive integer n to indicate the number of classes.

Output format:

In order to output all the students in the first column corresponding to the number, each of the two numbers separated by a space, the last number followed by no space.

Input Sample:

11

Sample output:

1 3 5 7 9 11

#include <stdio.h>int main () {int n;scanf ("%d", &n), int x=1;do{if (x%2 = = 1) {printf ("%d", x); if (n%2 = = 1 & & x<= n-2) {printf ("");} else if (n%2 = = 0 && x<= n-3) {printf ("");}} x + +;} while (x<=n); return 0;}

  

Onge C Language Introduction third week programming problem (revision) of "sub-queue"

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.