以下不是死循环的程序段是
#include
#include
int main()
{
int n = 1;
float term = 1, sum = 0;
______________;
while (fabs(term) >= 1e-4) //判末项大小
{
term = sign / n; //求出累加项
sum = sum + term; //累加
________________; //改变项的符号
n++; //分母加1
}
printf("sum = %f\n", sum);
return 0;
}
for(i=0,k=-1;k=1; i++,k++)
printf( "* * * *\n");
#include
int main()
{
int s=0,a=1,n;
scanf("%d",&n);
do
{
s+=1;
a=a-2;
} while(a!=n);
printf("%d\n",s);
return 0;
}
#include
int main()
{
int i, j, k;
for (i=0; i<=3; i++)
{
for (j=0; j<=3; j++)
{
for (________________)
{
if (__________________)
{
printf("i=%d, j=%d, k=%d\n", i, j, k);
}
}
}
}
return 0;
}
#include
int main()
{
int upper = 300, step = 20;
float fahr = 0, celsius;
while (fahr < upper)
{
_________________;
printf("%4.0f\t%6.1f\n", fahr, celsius);
________________ ;
}
return 0;
}
#include
#include
int main()
{
int n = 1, count = 1;
________________;
double term = 1.0;
while (fabs(term) >= 1e-5) //判末项大小
{
______________; //求出累加项
e = e + term; //累加
n++; // 计算下一项
_______________; //统计累加项数
}
printf("e = %f, count = %d\n", e, count);
return 0;
}
#include
int main()
{
int i, j, k, n;
printf("result is:");
for (n=100; ________; n++)
{
i = n / 100; //分离出百位
j = ____________; //分离出十位
k = ____________; //分离出个位
if (_________________________)
{
printf("%d\t ",n); //输出结果
}
}
printf("\n");
return 0;
}
#include
int main( )
{
int i,n=0;
for(i=2;i<5;i++)
{
do
{
if(i%3) continue;
n++;
}while(!i);
n++;
}
printf("n=%d\n",n);
return 0;
}
#include
int main()
{
int i=0,s=0;
for (;;)
{
if(i==3||i==5) continue;
if (i==6) break;
i++;
s+=i;
}
printf("%d\n",s);
return 0;
}
#include
int main( )
{
int i,s=0;
for(i=1;i<10;i+=2)
{
s+=i+1;
}
printf("%d\n",s);
return 0;
}
#include
int main( )
{
char k;
int i;
for(i=1;i<3;i++)
{
scanf("%c",&k);
switch(k)
{
case '0': printf("another\n");
case '1': printf("number\n");
}
}
return 0;
}
#include
int main( )
{
int x=0,y=5,z=3;
while(z-->0 && ++x<5)
{
y=y-1;
}
printf("%d,%d,%d\n",x,y,z);
return 0;
}
#include
int main()
{
int i;
for(i=0;i<3;i++)
switch(i)
{
case 0: printf("%d",i);
case 2: printf("%d",i);
default: printf("%d",i);
}
return 0;
}