该程序现在可以在不使用任何功能的情况下运行,但我想实现它们以使其更加模块化。
我的问题是我不知道如何使用函数,如何调用函数,如何实现它。现在我真的很困惑如何理解它们。
#include <stdio.h>
#include <conio.h>
#define BERBER 27.95
#define PILE 15.95
void main () {
int budget,lenh,wah,ftl,ftw;
float convert,area,costl,costw;
printf("WELCOME TO OUR SHOP!");
printf("\nWE SALE CARPETS");
printf("\nLength in <feet and inches>:\n");
scanf_s("%d %d",&lenh,&ftl);fflush(stdin);
printf("\nWidth in <feet and inches>:\n");
scanf_s("%d %d",&wah,&ftw);fflush(stdin);
costl=lenh(ftl/12.0);
costw=wah(ftw/12.0);
area=costl*costw;
printf("\nTotal cost of the length : %.2f",costl);
printf("\nTotal cost of the width : %.2f",costw);
printf("\nYour budget:");scanf("%d",&budget);
if (budget<BERBER) {
convert=area*PILE;
printf("\nYOu can only afford PILE");
} else if (budget>PILE) {
convert=area*BERBER;
printf("\nYou can afford BERBER");
} else {
printf("\nThe choose is in you if you choose BERBER or PILE");
}
getch();
}