Parity number Onge Teacher C Programming Cap 4th Chapter programming problem

Source: Internet
Author: User

Topic content:

Your program reads a series of positive integer data, input 1 indicates the end of the input, and 1 is not the input data itself. The number of odd and even numbers in the data read by the program output.

Input format:

A series of positive integers in which the range of integers is (0,100000). If input-1 indicates the end of the input.

Output format:

Two integers, the first integer representing the number of odd numbers in the read data, and the second integer representing the number of even numbers in the read data. Two integers are separated by a space.

Input Sample:

9 3 4 2 5 7-1

Sample output:

4 2

time limit: 500ms memory limit: 32000kb
#include <stdio.h>intMain () {intA, Ji =0, OU =0; scanf ("%d", &a);  while(A! =-1) {if((a%2) ==1) {Ji++; }Else{ou++; } scanf ("%d",&a);} printf ("%d%d", Ji,ou); return 0;}

Parity number Onge Teacher C Programming Cap 4th Chapter programming problem

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.