C語言設計實數四則運算運用MAKEFILE,程式如下
#include<stdio.h>
#include<stdlib.h>
#include<math.h>void jiafa()
{
double i,j;
printf("請輸入兩個實數:");
scanf("%lf %lf",&i,&j);
printf("%5.2f+%5.2f=%5.2f\n",i,j,i+j);
}void jianfa()
printf("%5.2f-%5.2f=%5.2f\n",i,j,i-j);
}
void chengfa()
printf("%5.2f*%5.2f=%5.2f\n",i,j,i*j);
void chufa()
printf("%5.2f/%5.2f=%5.2f\n",i,j,(double)i/j);
}void main()
int shuru=0;
char x;
system("pause");
system("cls");
while (1)
printf("你需要做什麼題型計算?請選擇:+(輸入1) - (輸入2) *(輸入3) /(輸入4)\n");
if(shuru==0)
scanf("%c",&x);
switch(x)
case "1": jiafa();break;
case "2": jianfa();break;
case "3": chengfa();break;
case "4": chufa();break;
default : printf("輸入錯誤,請重新輸入");
printf("請輸入數字選擇:\n1.繼續\n2.重新選擇題型\n3.結束\n");
scanf("%d",&shuru);
if(shuru==1) shuru=1;
if(shuru==2) {shuru=0;getchar();}
if(shuru==3) break;
C語言設計實數四則運算運用MAKEFILE,程式如下
#include<stdio.h>
#include<stdlib.h>
#include<math.h>void jiafa()
{
double i,j;
printf("請輸入兩個實數:");
scanf("%lf %lf",&i,&j);
printf("%5.2f+%5.2f=%5.2f\n",i,j,i+j);
}void jianfa()
{
double i,j;
printf("請輸入兩個實數:");
scanf("%lf %lf",&i,&j);
printf("%5.2f-%5.2f=%5.2f\n",i,j,i-j);
}
void chengfa()
{
double i,j;
printf("請輸入兩個實數:");
scanf("%lf %lf",&i,&j);
printf("%5.2f*%5.2f=%5.2f\n",i,j,i*j);
}
void chufa()
{
double i,j;
printf("請輸入兩個實數:");
scanf("%lf %lf",&i,&j);
printf("%5.2f/%5.2f=%5.2f\n",i,j,(double)i/j);
}void main()
{
int shuru=0;
char x;
system("pause");
system("cls");
while (1)
{
printf("你需要做什麼題型計算?請選擇:+(輸入1) - (輸入2) *(輸入3) /(輸入4)\n");
if(shuru==0)
scanf("%c",&x);
switch(x)
{
case "1": jiafa();break;
case "2": jianfa();break;
case "3": chengfa();break;
case "4": chufa();break;
default : printf("輸入錯誤,請重新輸入");
}
printf("請輸入數字選擇:\n1.繼續\n2.重新選擇題型\n3.結束\n");
scanf("%d",&shuru);
if(shuru==1) shuru=1;
if(shuru==2) {shuru=0;getchar();}
if(shuru==3) break;
}
}