Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:题目里明确说了2~15个数 为什么我数组开到了15 会越界??

Posted by Snow_storm at 2009-11-22 13:51:37 on Problem 1552
In Reply To:题目里明确说了2~15个数 为什么我数组开到了15 会越界?? Posted by:Snow_storm at 2009-11-22 13:50:34
> 无语掉。。。。。还是我英语水平太烂的缘故??
我的水程序
#include<iostream>
using namespace std;
int main()
{
	double s[100];
	do
	{
		int i=0,z=0;
		cin>>s[0];
		if(s[0]!=-1)
		{
			while(s[i]!=0)
			{
				i++;
				cin>>s[i];
			}
			int a,b;
			for(a=0;a<i;a++)
				for(b=0;b<i;b++)
					if(s[b]/s[a]==2)
						z++;
			cout<<z<<endl;
		}
	}while(s[0]!=-1);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator