#include <stdio.h>
int main(){
int 我=0;
while(我<=0){
//让用户输入一个正整数
printf("请输入一个正整数\n");
scanf ("%d",&我);
}
int sum =0;
int count =0;
while(count<我 ){
count++;
if(count % 2==0){
sum -=count;
}
else if(count % 2==1){
sum +=count;
}
}
printf("%d\n",sum);
return 0;
}
|
|