main()
{ float PI,n;
int i;
PI=1.0;
printf("n=");
scanf("%f",&n);
for(i=1;i<=n;i++)
PI*=8.0*n*n/(4.0*n*n-1.0);
printf("PI=%f\n",PI);
getch( );
}
第二题如上.....
念双燕,难凭音信;指幕天,空识归航!
方法很明朗~~
main()
{
int i,b5[5],b4[4],b3[3],b2[2];
int b1;
long a,c;
printf("input a number:\n");
scanf("%ld",&a);
if(a>99999||a<0) printf("the number is error!\n");
else if(a>9999)
{ printf("the number is 5 bit.\n");
for(i=0;i<5;i++)
{c=a;
a=a%10;
b5[i]=a;
a=c/10;
}
printf("the reverse sequence is:\n");
for(i=0;i<5;i++)
printf("%4d",b5[i]);
printf("\n");
}
else if(a>999)
{ printf("the number is 4 bit.\n");
for(i=0;i<4;i++)
{c=a;
a=a%10;
b4[i]=a;
a=c/10;
}
printf("the reverse sequence is:\n");
for(i=0;i<4;i++)
printf("%4d",b4[i]);
printf("\n");
}
else if(a>99)
{ printf("the number is 3 bit.\n");
for(i=0;i<3;i++)
{c=a;
a=a%10;
b3[i]=a;
a=c/10;
}
printf("the reverse sequence is:\n");
for(i=0;i<3;i++)
printf("%4d",b3[i]);
printf("\n");
}
else if(a>9)
{ printf("the number is 2 bit.\n");
for(i=0;i<2;i++)
{c=a;
a=a%10;
b2[i]=a;
a=c/10;
}
printf("the reverse sequence is:\n");
for(i=0;i<2;i++)
printf("%4d",b2[i]);
printf("\n");
}
else
{ printf("the number is 1 bit.\n");
b1=a;
printf("the reverse sequence is:\n");
printf("%d",b1);
printf("\n");
}
}
这是第二题的答案。其他都比较简单!自己多尝试一下!