#include<stdio.h>
#include<stdlib.h>
int Add();
int Sub();
int Mul();
float Div();
int Fac();
int Rem();
int Sum();
int main(void)
{
int x,y;
printf("进入登录页面\n");
printf("账号: ");
scanf("%d",&x);
printf("密码: ");
scanf("%d",&y);
getchar();
if(x==202504 && y==405202)
{
printf("——————恭喜你成功登录账号——————\n");
printf("-----------Loading----------\n");
printf("\n");
printf("!!!!欢迎使用R&Y计算器^_^!!!!");
int L;
while(L!=1)
{
printf("\n");
printf("-------------------分隔线------------------------\n");
printf("———————————————————————————————————————————————\n");
printf("| Q----加法 |\n");
printf("| W----减法 |\n");
printf("| E----乘法 |\n");
printf("| R----除法 |\n");
printf("| T----求余 |\n");
printf("| Y----阶乘 |\n");
printf("| U----累加 |\n");
printf("| I----结束 |\n");
printf("————————————————————————————————————————————————\n");
printf("Select a function: ");
int A;
A=getchar();
switch (A)
{
case 'Q':
Add();
break;
case 'W':
Sub();
break;
case 'E':
Mul();
break;
case 'R':
Div();
break;
case 'T':
Rem();
break;
case 'Y':
Fac();
break;
case 'U':
Sum();
break;
case 'I':
L=1;
printf("886");
break;
default:
getchar();
printf("!Not in the selection range!");
break;
}
}
}
else if(x!=202504 && y==405202)
printf("账号不存在");
else if(y!=405202 && x==202504)
printf("密码出错");
else
printf("账号密码错误");
}
int Add()
{int q,o,p;
printf("please enter two numbers to Addition: ");
scanf("%d %d",&o,&p);
getchar();
q=o+p;
printf("%d+%d=%d\n",o,p,q);}
int Sub()
{int w,o,p;
printf("please enter two numbers to subtraction: ");
scanf("%d %d",&o,&p);
getchar();
w=o-p;
printf("%d-%d=%d\n",o,p,w);}
int Mul()
{int e,o,p;
printf("please enter two numbers to multiplication: ");
scanf("%d %d",&o,&p);
getchar();
e=o*p;
printf("%d*%d=%d\n",o,p,e);}
float Div()
{float r,o,p;
printf("please enter two numbers to division: ");
scanf("%f %f",&o,&p);
getchar();
r=o/p;
printf("%.2f/%.2f=%.2f\n",o,p,r);}
int Rem()
{int t,o,p;
printf("please enter two numbers to remainder: ");
scanf("%d %d",&o,&p);
getchar();
t=o%p;
printf("%d余%d=%d\n",o,p,t);}
int Fac()
{int y=1,o,p;
printf("please enter one number to factorial: ");
scanf("%d",&o);
getchar();
for(p=1;p<=o;p++)
y*=p;
printf("%d的阶乘是%d\n",o,y);}
int Sum()
{int u=0,o,p;
printf("please enter one number to accumulation: ");
scanf("%d",&o);
getchar();
for(p=0;p<=o;p++)
u+=p;
printf("%d的累加是%d\n",o,u);}
计算器
最新推荐文章于 2021-10-16 14:48:38 发布