急啊!!!C语言流程图怎么画
问一下流程图和主要算法是什么谢谢了#include<math.h>main(){intnum;floata,b,x;intk,n,i,j,s=1,t=1,l=1;whil...
问一下流程图和主要算法是什么
谢谢了
#include<math.h>
main()
{
int num;
float a,b,x;
int k,n,i,j,s=1,t=1,l=1;
while(l==1)
{
printf("1.+\n2.-\n3.*\n4./\n5.pow\n6.Sqrt\n");
printf("7.sin\n8.cos\n9.tan\n");
printf("10.P\n11.C\n");
printf("\nplease choose a number(1-11):\n");
scanf("%d",&num);
switch(num)
{
case 1:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f+%f=%f\n",a,b,a+b);
break;
case 2:printf("please input a and b:\n") ;
scanf("%f %f",&a,&b);
printf("%f-%f=%f\n",a,b,a-b);
break;
case 3:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f*%f=%f\n",a,b,a*b);
break;
case 4:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f/%f=%f\n",a,b,(float)a/b);
break;
case 5:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("Pow(%f,%f)=%f\n",a,b,pow(a,b));
break;
case 6:printf("please input x:\n");
scanf("%f",&x);
printf("Sqrt(%f)=%f\n",x,sqrt(x));
break;
case 7:printf("please input x:\n");
scanf("%f",&x);
printf("Sin(%f)=%f\n",x,sin(x));
break;
case 8:printf("please input x:\n");
scanf("%f",&x);
printf("Cos(%f)=%f\n",x,cos(x));
break;
case 9:printf("please input x:\n");
scanf("%f",&x);
printf("Tan(%f)=%f\n",x,tan(x));
break;
case 10:printf("please input k and n:\n");
scanf("%d %d",&k,&n);
for(i=n;i>=n-k+1;i--)
{
s=s*i;
}
printf("P(%d,%d)=%d\n",k,n,s);
break;
case 11:printf("please input k and n:\n");
scanf("%d %d",&k,&n);
for(i=n;i>=n-k+1;i--)
{
s=s*i;
}
for(j=k;j>=1;j--)
{
t=t*j;
}
s=s/t;
printf("C(%d,%d)=%d\n",k,n,s);
break;
default:printf("error!\n");
}
printf("If you want to be continue ,please enter 1 \n");
printf("If you want to exit,please enter 0 \n");
printf("Enter your choice:");
scanf("%d",&l);
}
} 展开
谢谢了
#include<math.h>
main()
{
int num;
float a,b,x;
int k,n,i,j,s=1,t=1,l=1;
while(l==1)
{
printf("1.+\n2.-\n3.*\n4./\n5.pow\n6.Sqrt\n");
printf("7.sin\n8.cos\n9.tan\n");
printf("10.P\n11.C\n");
printf("\nplease choose a number(1-11):\n");
scanf("%d",&num);
switch(num)
{
case 1:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f+%f=%f\n",a,b,a+b);
break;
case 2:printf("please input a and b:\n") ;
scanf("%f %f",&a,&b);
printf("%f-%f=%f\n",a,b,a-b);
break;
case 3:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f*%f=%f\n",a,b,a*b);
break;
case 4:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("%f/%f=%f\n",a,b,(float)a/b);
break;
case 5:printf("please input a and b:\n");
scanf("%f %f",&a,&b);
printf("Pow(%f,%f)=%f\n",a,b,pow(a,b));
break;
case 6:printf("please input x:\n");
scanf("%f",&x);
printf("Sqrt(%f)=%f\n",x,sqrt(x));
break;
case 7:printf("please input x:\n");
scanf("%f",&x);
printf("Sin(%f)=%f\n",x,sin(x));
break;
case 8:printf("please input x:\n");
scanf("%f",&x);
printf("Cos(%f)=%f\n",x,cos(x));
break;
case 9:printf("please input x:\n");
scanf("%f",&x);
printf("Tan(%f)=%f\n",x,tan(x));
break;
case 10:printf("please input k and n:\n");
scanf("%d %d",&k,&n);
for(i=n;i>=n-k+1;i--)
{
s=s*i;
}
printf("P(%d,%d)=%d\n",k,n,s);
break;
case 11:printf("please input k and n:\n");
scanf("%d %d",&k,&n);
for(i=n;i>=n-k+1;i--)
{
s=s*i;
}
for(j=k;j>=1;j--)
{
t=t*j;
}
s=s/t;
printf("C(%d,%d)=%d\n",k,n,s);
break;
default:printf("error!\n");
}
printf("If you want to be continue ,please enter 1 \n");
printf("If you want to exit,please enter 0 \n");
printf("Enter your choice:");
scanf("%d",&l);
}
} 展开
4个回答
展开全部
switch流程图: http://phys.thu.edu.tw/~ctshih/teach/c_prog/switch.ppt
分支由一个菱形框画出来就行。。。
分支由一个菱形框画出来就行。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
调用的地方画个箭头到子程序
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
调用的地方画个箭头到子程序
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询