本文目錄一覽:
用C語言寫,簡單的手機沖值程序,跪求!!!沒財富了,寫出來了我給你充話費都行~~
int phonetime, 電話時間
int smscount 信息條數
double m1 = phonetime * 100;
double m2 = (((smscount20)20:smscount)-20)*20;
if(m1 10000)m1=10000;
if(phonetime = 500)m1 = m1 * 0.9;
if(smscount = 200)m2 = m2 * 0,9
tax=0.1*(m1 + m2);
tax 稅率
m1+m2合計
充值總額m1+m2+tax
求C語言編寫的班費管理系統程序
#include stdio.h
#include string.h
#include stdlib.h
#pragma pack(1)
const char *DataFilename = “d:\\classfee.data”;
typedef struct classfee ClassFee;
struct classfee{
int id;
char io;
char cbr[10];
char reason[256];
float fee;
char memo[256];
float restfee;
ClassFee *next;
};
void ShowMenu() {
const char *menu = {
“1.添加班費收支信息\n”
“2.瀏覽所有班費收支信息\n”
“3.查詢班費收支信息\n”
“4.修改班費收支信息\n”
“5.退出\n請選擇:\n”
};
printf(“%s”, menu);
}
ClassFee *fee;
int index = 0;
float lastfee = 0.0f;
int InitDataFile() {
FILE *fp = fopen(DataFilename, “rb”);
size_t sizefee = sizeof(ClassFee);
fee = (ClassFee*)malloc(sizefee);
fee-next = NULL;
if (fp==NULL) {
return 1;
}
ClassFee *p = fee;
size_t len;
while (!feof(fp)) {
ClassFee *q = (ClassFee*)malloc(sizefee);
len = fread((char*)q, sizefee, 1, fp);
if (len==1) {
index++;
lastfee = q-restfee; //最後一次取得數據為最後餘額
q-next = NULL;
p-next = q;
p = q;
}
}
fclose(fp);
return 0;
}
int WriteDataFile() {
FILE *fp = fopen(DataFilename, “wb”);
if (fp==NULL) {
printf(“無法打開數據文件:%s,請檢查。\n”, DataFilename);
return 1;
}
size_t sizefee = sizeof(ClassFee);
ClassFee *p = fee-next;
while (p) {
fwrite((char *)p, sizefee, 1, fp);
p = p-next;
}
fclose(fp);
return 0;
}
void FreeResource() {
ClassFee *p = fee, *q=NULL;
while (p) {
q = p-next;
free(p);
p=q;
}
}
void AppendFee(ClassFee *f) {
ClassFee *p = fee, *q;
q = p-next;
while (q) {
p=q;
q=p-next;
}
p-next = f;
}
void InputFee() {
ClassFee *p = (ClassFee*)malloc(sizeof(ClassFee));
p-id = ++index;
fflush(stdin);
printf(“輸入費用信息:\n”);
printf(” 支出(o)?收入(i)?:”);
scanf(“%c”, p-io);
if (p-io!=’i’ p-io!=’o’) {
printf(“輸入錯誤,按收入處理,此處應該做成循環輸入,直到輸入成功為止,這裡省略\n”);
p-io=’i’;
}
printf(” 經辦人:”);scanf(“%s”, p-cbr);
printf(” 原因:”);scanf(“%s”, p-reason);
printf(” 金額:”);scanf(“%f”, p-fee);
printf(” 備註:”);scanf(“%s”, p-memo);
p-restfee = p-io==’i’?(lastfee+p-fee):(lastfee-p-fee);
lastfee = p-restfee;
p-next = NULL;
AppendFee(p);
printf(“————————————————-\n”);
}
void DisplayFee(ClassFee *p) {
printf(” 收支編號 : %d\n”, p-id);
printf(” 收入/支出: %s\n”, p-io==’i’?”收入”:”支出”);
printf(” 經辦人 : %s\n”, p-cbr);
printf(” 原因 : %s\n”, p-reason);
printf(” 金額 : %.2f\n”, p-fee);
printf(” 備註 : %.2f\n”, p-memo);
printf(” 餘額 : %.2f\n”, p-restfee);
printf(“————————————————-\n”);
}
void Search() {
int s;
const char *msg[] = {“輸入收支編號:”, “輸入原因:”};
printf(“輸入查詢條件:\n 1.按收支編號查詢\n 2.按原因查詢:”);
fflush(stdin);
scanf(“%d”, s);
ClassFee *p = fee-next;
if (s==1) {
size_t s0;
printf(“%s”, msg[s-1]);
scanf(“%d”, s0);
while (p) {
if (p-id==s0) {
DisplayFee(p);
break;
}
p=p-next;
}
} else if (s==2) {
char r[256];
printf(“%s”, msg[s-1]);
scanf(“%s”, r);
while (p) {
if (strstr(p-reason, r)!=NULL) {
DisplayFee(p);
}
p=p-next;
}
}
}
void ModifyFee() {
size_t s;
printf(“輸入收支編號:”);
scanf(“%d”, s);
ClassFee *p = fee-next;
while (p) {
if (p-id==s) {
DisplayFee(p);
printf(“輸入修改信息:\n——————————-\n”);
//這裡對p進行修改,這個比較麻煩,不單單是修改本節點的信息
//如果對fee和收入/支出做了修改,則需要修改後續所有節點的restfee的信息
//有點麻煩,不想寫了,你自己補上這塊即可。
break;
}
p=p-next;
}
}
int main() {
int choice;
InitDataFile();
printf(“index=%d, lastfee=%.2f\n”, index, lastfee);
while (1) {
ShowMenu();
scanf(“%d”, choice);
if (choice1 || choice5) {
system(“cls”);
printf(“你的輸入錯誤,請重新輸入\n————————\n”);
continue;
} else {
if (choice==5) {
WriteDataFile();
break;
} else if (choice==1) {
InputFee();
} else if (choice==2) {
system(“cls”);
ClassFee *p = fee-next;
while (p) {
DisplayFee(p);
p=p-next;
}
} else if (choice ==3) {
Search();
} else if (choice ==4) {
ModifyFee();
}
}
}
return 0;
}
要求用C語言編寫一個會員卡計費管理系統。
可以購買個現成的系統,一卡易連鎖會員卡系統
我們公司做這方面系統有5、6年經驗了,全國客戶超過萬家門店
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/241447.html