A. IQ test
来源:互联网 发布:淘宝网笔袋 编辑:程序博客网 时间:2024/05/18 01:45
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
52 4 7 8 10
3
41 2 1 1
2
解题说明:此题判断奇偶性即可
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int main(){int n,i;int count1,count2;int a[101];scanf("%d",&n);count1=0;count2=0;for(i=0;i<n;i++){scanf("%d",&a[i]);if(a[i]%2==0){count2++;}else{count1++;}}if(count1==1){for(i=0;i<n;i++){if(a[i]%2==1){printf("%d\n",i+1);break;}}}if(count2==1){for(i=0;i<n;i++){if(a[i]%2==0){printf("%d\n",i+1);break;}}}return 0;}
- A. IQ test
- A. IQ Test
- A. IQ test
- codeforces 328A. IQ Test
- codeforces A. IQ test 题解
- Codeforces 25A IQ test
- 【CodeForces】[25A]IQ test
- CodeForces Testing Round #8 A.IQ Test
- Codeforces-287a C IQ Test
- 【水模拟】#25 A. IQ test
- Codeforces 328A-IQ Test(数列)
- CodeForces 25A IQ test 唯一奇偶
- IQ Test
- codeforces-25A-A. IQ test( C && 怡宝 )
- Codeforces Testing Round #8 / 328A IQ Test(模拟)
- Codeforces Beta Round #25 (Div. 2)--A. IQ test
- CodeForces 25A IQ test 唯一奇偶(简单的题目)
- codeforces——25A——IQ test
- 基于stm32f103zet6的FAT16文件系统学习2(初步移植ff9a)
- B. Find Marble
- VC++ 创建Windows服务
- win7局域网共享文件设置
- DNA Sorting(DNA排序)
- A. IQ test
- pthread线程创建出现undefined reference to `pthread_create' collect2: error: ld returned 1 exit status
- 数据结构实验之栈三:后缀式求值
- http状态码
- JSONKin的简单用法
- C语言面试题大汇总之华为面试题 .
- Linux权限机制
- smartform 中currency 字段的小数点问题
- 好代码起提示作用