任意输入一个正整数N,统计1~N之间奇数的个数和偶数的个数,并输出。
#include <stdio.h> int main(){ int n, count = 0; scanf("%d", &n); for(int i = 1; i <= n; i++){ if(i % 2 == 0) count++; } printf("%d %d", n - count, count); return 0; }
while(a = readline()){ a = parseInt(a); var B = 0; var A = 0; for(i = 1;i <= a;i++){ if(i%2 == 1) B++; else A++; } console.log(B,A); }
int main() { int N = 0; scanf("%d", &N); if(N % 2 ==0) //N为偶数 printf("%d %d",N/2,N/2); else //N为奇数 printf("%d %d", N/2+1,N/2); return 0; }
N = int(input()) M = int((N+1)/2) O = int(N/2) if N%2==0: print(O,O) else: print(M,M-1)