POJ 1552 Doubles (水题)
来源:互联网 发布:南京plc编程培训机构 编辑:程序博客网 时间:2024/06/05 15:24
题意:给出几个正数(2~15个),然后就是求有这些数字的2倍有没有和原先的正数相同的,求出有几个,没有就是0.
分析:水题。用数组解决,开一个数组存正数,另开一个数组用来存这些数的2倍,接着就搜索,然后注意一下结束的时候怎么处理就行。
贴下代码:(248k,0ms)
C++语言:
#include<iostream>
usingnamespacestd;
intmain()
{
int a[20]={0};
int b[20]={0};
int i,j;
int length;
int temp; //计数器,记录有几个相同的
while(cin>>a[0]&&a[0]!=-1)
{
b[0]= 2*a[0];
for(i =1;;i ++)
{
cin>>a[i];
if(a[i]== 0)break;
b[i]= 2*a[i];
}
length= i;
temp= 0;
for(i =0 ;i < length ; i ++)
{
for(j= 0 ; j < length ; j ++)
{
if(b[j]==a[i])temp++;
}
}
cout<<temp<<endl;
}
}
usingnamespacestd;
intmain()
{
}
- POJ 1552 Doubles (水题)
- HDU 1303 Doubles
- hdu 1303 doubles …
- POJ 1046 Color Me Less(水题)
- ACM: 水题 分数运算 poj 3979
- poj 2488
- POJ 2485 Highways
- POJ 3299
- poj 1905
- POJ 1207(The 3n + 1 problem)水题
- POJ 1552
- POJ 2247 Humble Numbers
- POJ 1753 Flip Game
- POJ 1182 食物链
- POJ 3185 The Water Bowls
- POj 2379 ACM Rank Table
- POJ 1018 Communication System
- POJ 1050 To the Max
- 常用的一些东东,多复习。
- substr与substing的区别
- (重要题目)POJ 1226 Substrings(…
- POJ 1401 Factorial (对数学知识考…
- POJ 1504 Adding Reversed Numbers…
- POJ 1552 Doubles (水题)
- POJ 1658 Eva's Problem(水到极点)
- android 打开各种文件(setDataAndType)
- POJ 1674 Sorting by Swapping(需…
- POJ 1607 Deck(n 块相同的木板重叠…
- Java程序绑定:动态与静态
- TimeZone里的daylight savings
- POJ 1799 (Yeehaa!)(数学题)
- POJ 1862 (Stripies) 数学题