日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

居民水费管理系统

發(fā)布時間:2024/3/24 windows 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 居民水费管理系统 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

#include<stdio.h>
#include<string.h>
#define N 2
struct waterfee
{
?? ?char name[20];
?? ?int cardid;
?? ?int totalvolume;
?? ?int monthvolume[12];
?? ?int checked;
?? ?int fee;//欠費?
?? ?int residual;//余額?
?} ;//1.
?struct waterfee wfs[N];
?int initialize = 0;
?char usename[]="yt",password[]="123";
?void printfhelp();
?void initializeinfo(struct waterfee x[],int n);
?double calcfee(int volume);//5.
?void sorttotal(struct waterfee x[],int n);//6.
?void printrecord(struct waterfee x[],int n);//3.1)
?void printarecord(struct waterfee x[],int idx);//3.2)
?int find(struct waterfee x[],int n,int cardid);
?void payfee(struct waterfee x[],int idx);//4.
?int main(void)
?{
??? ?int choice,idx;
??? ?int cardid;
??? ?char user[100],ps[100];
??? ?printf("請輸入用戶名:");
?? ? gets(user);
?? ? printf("請輸入密碼:");
?? ? gets(ps);
?? ? if(strcmp(user,usename) || strcmp(ps,password))?
?? ? {
?? ? ?? ?printf("用戶名或密碼錯誤,退出系統(tǒng)!\n");
?? ? ?? ?return 0;
?? ? }
?? ? printfhelp();
?? ? while(1)
?? ? {
?? ? ?? ?printf("請輸入一個0-7的整數(shù):");
?? ??? ? scanf("%d",&choice);
?? ??? ? while(choice<0 || choice>7)
?? ??? ? {
?? ??? ? ?? ?printf("請輸入一個0-7的整數(shù):");
?? ??? ??? ? scanf("%d",&choice);?
?? ??? ? ?}?
?? ??? ? ?switch(choice)
?? ??? ? ?{
?? ??? ? ??? ?case 0:
?? ??? ? ??? ?initializeinfo(wfs,N);//初始化數(shù)據(jù)
?? ??? ??? ?initialize = 1;
?? ??? ??? ?break;
?? ??? ??? ?case 1:
?? ??? ??? ?printf("查詢時請輸入你的卡號:");
?? ??? ??? ?scanf("%d",&cardid);
?? ??? ??? ?idx=find(wfs,N,cardid);
?? ??? ??? ?if(idx==-1)
?? ??? ??? ?printf("卡號不存在!\n");
?? ??? ??? ?else
?? ??? ??? ?printarecord(wfs,idx);//輸出一條記錄
?? ??? ??? ?break;
?? ??? ??? ?case 2:
?? ??? ??? ?printf("繳費前請輸入你的卡號:");
?? ??? ??? ?scanf("%d",&cardid);
?? ??? ??? ?idx=find(wfs,N,cardid);
?? ??? ??? ?if(idx==-1)
?? ??? ??? ?printf("卡號不存在!\n");
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?payfee(wfs,idx);//個人繳費
?? ??? ??? ??? ?printarecord(wfs,idx);?
?? ??? ??? ? }?
?? ??? ??? ? break;
?? ??? ??? ?case 4:
?? ??? ??? ?sorttotal(wfs,N);
?? ??? ??? ?break;
?? ??? ??? ?case 5:
?? ??? ??? ?printfhelp();
?? ??? ??? ?break;
?? ??? ??? ?case 6:
?? ??? ??? ?printrecord(wfs,N);
?? ??? ??? ?break;
?? ??? ? ?}
?? ??? ? ?if(choice == 7)
?? ??? ? ?break;
?? ? }
?? ? return 0;
?}//2.
?
void printfhelp()
{
?? ?printf("**********使用幫助*********\n");
?? ?printf("[0]數(shù)據(jù)初始化\n");
?? ?printf("[1]查詢個人賬戶\n");
?? ?printf("[2]個人繳費\n");
?? ?printf("[3]欠費信息匯總\n");
?? ?printf("[4]數(shù)據(jù)排序\n");
?? ?printf("[5]調(diào)出菜單\n");
?? ?printf("[6]輸出所有用戶用水詳情\n");
?? ?printf("[7]退出系統(tǒng)\n");
?? ?printf("***************************\n");?? ?
}

void initializeinfo(struct waterfee x[],int n)
{
?? ?int i,j;
?? ?int totalvolume;
?? ?for(i=0;i<n;i++)
?? ?{
?? ??? ?totalvolume=0;
?? ??? ?printf("輸入用戶姓名:");
?? ??? ?fflush(stdin);
?? ??? ?gets(x[i].name);
?? ??? ?printf("輸入用戶水卡編號:");
?? ??? ?scanf("%d",&x[i].cardid);
?? ??? ?x[i].checked=0;
?? ??? ?fflush(stdin);
?? ??? ?for(j=0;j<12;j++)
?? ??? ?{
?? ??? ??? ?printf("第%d個月的用水量:",j+1);
?? ??? ??? ?scanf("%d",&x[i].monthvolume[j]);//月份的合法性?
?? ??? ??? ?while(x[i].monthvolume[j]<0)
?? ??? ??? ?scanf("%d",&x[i].monthvolume[j]);
?? ??? ??? ?totalvolume+=x[i].monthvolume[j];
?? ??? ? }?
?? ??? ? x[i].totalvolume=totalvolume;?
?? ??? ? x[i].residual=0;
?? ??? ? x[i].fee=(int)calcfee(x[i].totalvolume);
?? ?}
}

double calcfee(int volume)/7olume隱式保持非負
{
?? ?double pay=0;
?? ?double n1,n2;
?? ?n1=1500;
?? ?n2=n1+2200;
?? ?if(volume<100)
?? ?{
?? ??? ?pay=volume*1.5;
?? ?}
?? ?else if(volume<200)
?? ?{
?? ??? ?pay=n1+(volume-100)*2.2;
?? ?}
?? ?else
?? ?pay=n2+(volume-200)*3;
?? ?return pay;
?}

void sorttotal(struct waterfee x[],int n)
{
?? ?int i,j;
?? ?struct waterfee t;
?? ?if(!initialize)
?? ?{
?? ??? ?printf("數(shù)據(jù)未進行初始化,排序失敗!\n");
?? ??? ?return;
?? ? }?
?? ? for(i=0;i<n-1;i++)
?? ? {
?? ? ?? ?for(j=0;j<n-1-i;j++)
?? ? ?? ?{
?? ? ?? ??? ?if(x[j].totalvolume>x[j+1].totalvolume)
?? ? ?? ??? ?{
?? ? ?? ??? ??? ?t=x[j];x[j]=x[j+1];x[j+1]=t;
?? ??? ??? ? }
?? ??? ? }
?? ? }
?}
?
?
?void printarecord(struct waterfee x[],int idx)
?{
??? ?int j;
??? ?if(!initialize)
??? ?{
??? ??? ?printf("數(shù)據(jù)未進行初始化!\n");
??? ??? ?return;
?? ? }
?? ? printf("第%d個用戶的信息\n",idx+1);
?? ? puts(x[idx].name);
?? ? printf("水卡編號:%d\n",x[idx].cardid);
?? ? printf("總用水量:%d噸\n",x[idx].totalvolume);
?? ? printf("每月用水詳情:\n");
?? ? for(j=0;j<12;j++)
?? ? {
?? ? ?? ?printf("第%d個月的用水量:%d\n",j+1,x[idx].monthvolume[j]);
?? ? ?}?
?? ? ?if(x[idx].checked)
?? ? ?printf("當前費用已繳清!\n");
?? ? ?else
?? ? ?printf("用戶欠費:%d\n",x[idx].fee);
?? ? ?printf("用戶當前余額:%d\n",x[idx].residual);?
?}//5.
?
void printrecord(struct waterfee x[],int n)
{
?? ?int i;
?? ?if(!initialize)
?? ?{
?? ??? ?printf("數(shù)據(jù)未進行初始化!\n");
?? ??? ?return;
?? ?}
?? ?for(i=0;i<n;i++)
?? ?printarecord(x,i);
}

//根據(jù)卡號找出索引?
int find(struct waterfee x[],int n,int cardid)
{
?? ?int i,res=-1;
?? ?for(i=0;i<n;i++)
?? ?{
?? ??? ?if(x[i].cardid==cardid)
?? ??? ?{
?? ??? ?res=i;
?? ??? ?break;
?? ??? ?}
?? ?}
?? ?return res;
}

//繳費或充值
void payfee(struct waterfee x[],int idx)
{
?? ?int money;
?? ?if(!initialize)
?? ?{
?? ??? ?printf("數(shù)據(jù)未進行初始化!\n");
?? ??? ?return;
?? ?}
?? ?scanf("%d",&money);
?? ?while(money<=0)
?? ?scanf("%d",&money);
?? ?if(x[idx].fee>0)
?? ?{
?? ??? ?if(money<x[idx].fee)
?? ??? ?x[idx].fee-=money;
?? ??? ?else
?? ??? ?{
?? ??? ??? ?x[idx].fee=0;
?? ??? ??? ?x[idx].checked=1;
?? ??? ??? ?x[idx].residual=money-x[idx].fee;
?? ??? ?}
?? ?}
?? ?else
?? ?{
?? ??? ?x[idx].residual+=money;
?? ? } ?? ?
?}

?

總結

以上是生活随笔為你收集整理的居民水费管理系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。