#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void print()
{
printf("*************计算方形的周长和面积 ***********\n");
printf("*******************************************\n");
printf("*************选择你想要进行的操作:>**********\n");
printf("*******************************************\n");
printf("*****1.计算周长*****2.计算面积***3.exit******\n");
}
//计算周长
int C(int a, int b)
{
int c = 0;
return c = (2*a+2*b);
}
//计算面积
int S(int d, int h)
{
int s = 0;
return s = (d * h);
}
int main()
{
print();
int x, y = 0;
int flag = 0;
scanf("%d", &flag);
if (flag == 3)
return 0;
printf("请输入要计算的两个边长:>");
scanf("%d%d",&x,&y);
int c= C(x,y);
int s = S(x, y);
switch (flag)
{
case 1 :
printf("方形的周长为:> %d\n",c);
break;
case 2:
printf("方形的面积为:> %d\n",s);
break;
case 3:
break;
default:
printf("输入错误:>");
break;
}
return 0;
}
标签:并求,return,周长,int,出该,长方形,break,flag,printf
From: https://blog.51cto.com/u_16425777/8805993