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

求好心人帮看一下哪里错了一直WA

Posted by nntk at 2012-06-06 20:07:16 on Problem 2262
#include <stdio.h>
#include <math.h>
void setBuffer(int a[], int lenth);
int s[78497];
int main ( void )
{
	long int n = 0;
	long int i, j;
	setBuffer(s, 78497);
	
	while ( scanf("%d", &n) == 1 && n )
	{
		for ( i = 0; i < n; i ++ )
		{
			
			for ( j = (78496>n)?n:78496; j > i; j -- )
			{
				if ( s[i] + s[j] == n )
				{
					printf("%d = %d + %d\n", n, s[i], s[j]);
					n = 0;
					break;
				}
				if ( s[i] + s[j] < n )
					break;
			}
		}
	}
	return 0;
}
void setBuffer(int a[], int lenth)
{
	FILE *fp = NULL;
	long int i = 0;
	fp = fopen("s.txt", "r"); //这个文件保存了1000000以内的奇素数
	for ( i = 0; i < lenth; i ++ )
		fscanf(fp, "%d", &a[i]);
	fclose(fp);
}

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