int fun(int n)
{
int sum=0;
for(int i=1;i<=n;i++)
{
if(i%2!=0)
{
sum+=i;
}
else
{
sum-=i;
}
}
return sum;
}
//---------------------------------------------------------------------------
#include
int sum(void)
{
int i,s,fg=1;
for (s=0,i=1; i <= 10; i++) {
s+=i*fg;
fg*=-1;
}
return s;
}
int main(void)
{
printf("%d",sum());
return 0;
}
//---------------------------------------------------------------------------
只是到10吗?