#include <stdio.h>
int main()
{
int i=1,sum=0,p=1;
while(i<=100)
{
sum=sum+i*p,i=i+1,p=p*-1;
}
printf("sum=%d\n",sum);
return 0;
}
成功
int main()
{
int i=1,sum=0,p=1;
while(i<=100)
{
sum=sum+i*p,i=i+1,p=p*-1;
}
printf("sum=%d\n",sum);
return 0;
}
成功
2021-09-11
#include <stdio.h>
int main()
{
int i=1,sum=0,p=1;
for(i=1;i<=100;i=i+1,p=(p+1)*-1)
{
sum=sum+p;
}
printf("sum=%d\n",sum);
return 0;
}
成功!!!
int main()
{
int i=1,sum=0,p=1;
for(i=1;i<=100;i=i+1,p=(p+1)*-1)
{
sum=sum+p;
}
printf("sum=%d\n",sum);
return 0;
}
成功!!!
2021-09-11
最新回答 / 慕妹5070519
JAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAV...
2021-09-10
最新回答 / 慕妹5070519
#include <stdio.h>int main(){ double num = 2.5; //定义浮点型变量num并赋值为2.5 int num2=(int)num; printf("num的整数部分是%f\n", num); printf("num2的整数部分%d\n",num2); return 0;}JAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJA...
2021-09-10
最新回答 / 慕妹5070519
#include <stdio.h> int main() { int num,sd,td,hd; for(num=100;num<1000;num++) { hd/100; td/100%10; sd%10; if(num==hd*hd*hd+td*td*td+sd*sd*sd); printf("水仙花数字:%d\n",num); } return 0; }JAVAJAVAJAVAJAVAJAV...
2021-09-09
最新回答 / 慕妹5070519
if后面为什么不能用数字JAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAV...
2021-09-09
最新回答 / 慕妹5070519
#include <stdio.h>int main(){ int x,y; int a,b,c,d,e; x = 10; y = -3; a=x+y; b=x-y; c=x*y; d=x/y; d=x%y; printf("x+y=%d\n", a ); printf("x-y=%d\n", b ); printf("x*y=%d\n", c ); printf("x/y=%d\n", d...
2021-09-09
最新回答 / 慕妹5070519
#include <stdio.h>int main() { int year = 2014; //今年是2014年 if(year%4 == 0) printf("今年是闰年"); else printf("今年是平年"); return 0;//补全一下代码 JAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVAJAVA...
2021-09-09