[mw_shl_code=c,true]#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
void zhengshu()
{
system("cls");
int a,b;
char c;
scanf("%d%c%d",&a,&b,&c);
if(c=='+')
printf("%d",a+b);
if(c=='-')
printf("%d",a-b);
if(c=='*')
printf("%d",a*b);
if(c=='/')
printf("%d",a/b);
system("pause");
return 0;
}
void xiaoshu()
{
system("cls");
float a,b;
char c;
scanf("%d%c%d",&a,&b,&c);
if(c=='+')
printf("%d",a+b);
if(c=='-')
printf("%d",a-b);
if(c=='*')
printf("%d",a*b);
if(c=='/')
printf("%d",a/b);
system("pause");
return 0;
}
int main()
{
char c=0;
srand(time(NULL));
while(1)
{
printf("-----计算器-----\n");
printf("1.整数计算 \n");
printf("2.小数计算 \n");
printf("3.退出 \n");
printf("----------------\n");
while(c<'1'||c>'3')
{
printf("\n输入有误。。\n你的选项是:");
c=getch();
}
if(c=='1')zhengshu();
if(c=='2')xiaoshu();
if(c=='3')return 0;
system("pause");
return 0;
}[/mw_shl_code]
找茬 |