Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用类似与这种算法的同学注意初始化!!!!#include<iostream> using namespace std; int main() { int i,cx=0; bool a[100]; while(cin>>i) { memset(a,0,sizeof(a));//要在这里初始化a数组 if(i==-1)break; a[i]=true; while(cin>>i) { if(i==0) break; a[i]=true; } cx=0; for(i=1;i<50;i++) if(a[i]==true&&a[i*2]==true) cx++; cout<<cx<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator