//使用for循环
for(i=1;i<=100;i++)
{
sum += i%2?i:-i;
}
printf("sum=%d\n",sum);
for(i=1;i<=100;i++)
{
sum += i%2?i:-i;
}
printf("sum=%d\n",sum);
2020-10-14
for(i=1;i<=100;i++)
{
if(i%2)
{
sum += i;
}
else
{
sum -= i;
}
}
printf("sum=%d\n",sum);
{
if(i%2)
{
sum += i;
}
else
{
sum -= i;
}
}
printf("sum=%d\n",sum);
2020-10-14
//使用for循环
for(i=1;i<=100;i++)
{
if(!i%2)
{
sum += i;
}
else
{
sum -= i;
}
}
printf("sum=%d\n",sum);
for(i=1;i<=100;i++)
{
if(!i%2)
{
sum += i;
}
else
{
sum -= i;
}
}
printf("sum=%d\n",sum);
2020-10-14
for(num=100; num<1000; num++)
{
hd = num/100;
td = num%100/10;
sd = num%100%10;
if(num == hd*hd*hd + td*td*td + sd*sd*sd)
{
printf("水仙花数字:%d\n", num);
}
}
{
hd = num/100;
td = num%100/10;
sd = num%100%10;
if(num == hd*hd*hd + td*td*td + sd*sd*sd)
{
printf("水仙花数字:%d\n", num);
}
}
2020-10-14