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

定义一个函数,效果好一点!!

Posted by 00430030 at 2005-01-11 17:04:15 on Problem 1218
In Reply To:各路高人,帮帮忙,就快考试了。怎么会是RUNTIME ERROR 呢? Posted by:tigerqian at 2005-01-07 17:21:51
#include<stdio.h>
#include<math.h>
int f(int n)
{
	int i,p=0;
	for(i=1;i<=n;i++)
		if(n%i==0)  p++;
		return p;
}
void main()
{
	int n,a,k,j,p;
		scanf("%d",&n);
        for(p=0;p<n;p++)
		{
		k=0;
		scanf("%d",&a);
	    for(j=1;j<=a;j++)
		if(f(j)%2)  k++;
		printf("%d\n",k);
	}
}
		

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