| ||||||||||
| 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 | |||||||||
定义一个函数,效果好一点!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator