请问我这样编程对吗?
#include <stdio.h>
int main()
{
int sum = 0,i,k;
for(i=1,k=1;i<=100;i++,k++)
{
if(k%2==0){
i*=-1;
}
sum+=i; } printf("sum=%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0,i,k;
for(i=1,k=1;i<=100;i++,k++)
{
if(k%2==0){
i*=-1;
}
sum+=i; } printf("sum=%d\n",sum);
return 0;
}
2018-02-22
举报