问一道关于记账的c语言程序

问一道关于记账的c语言程序,第1张

#include<stdio.h>

void fun(){

int i, ch float  price = 9.8, in_price, total = 0 while (1){

printf("\n1.算账模式\n2.算账\n3.退出\n")

scanf("%d", &i)

switch (i){

case 1://算账模式

{

   do{

   printf("应付款金额 %f 元.\n付款金额:", price)

   scanf("%f", &in_price)

   printf("实际付款金额%f,应找零金额 %f 元.\n", in_price, in_price - price)

   total += price

   scanf("%d", &ch)

   } while (ch != -1)

   break

}

case 2:{

   printf("收款总额:%6.2f 元.\n", total) break

}

case 3:

exit(0)

}

}

}

void main()

{

fun()

}

#include <stdio.h>

#include <stdlib.h>

typedef struct moneydata

{

double n

struct moneydata* next

}NUM

//main

int main()

{

NUM* initial()

NUM* build(NUM* money)

void input(NUM* income,NUM* payment)

void output(NUM* income,NUM* payment)

double incomeSum(NUM* income)

double paymentSum(NUM* income)

double toplimit

double SUM

char ch

NUM *income,*payment

printf("enter your payment toplimit\n")

scanf("%lf",&toplimit)

fflush(stdin)

printf("*************************************************\n\n")

income=initial()

payment=initial()

for()

{

printf("please choose what you want to do\n")

printf("1.input 2.analyse 3.quit\n")

scanf("%c",&ch)

fflush(stdin)

printf("*************************************************\n\n")

switch(ch)

{

//输入函数,对收入支出的输入处理

case '1':

input(income,payment)

printf("*************************************************\n\n")

break

//数据分析,包括输出收入总和,支出总和,对收入支出比较,输出利润和提醒是否要存钱了

case '2':

printf("please choose what you want to do\n")

printf("1.output income's sum 2.output payment's sum 3.compare with toplimit\n")

scanf("%c",&ch)

fflush(stdin)

switch(ch)

{

case '1':

SUM=incomeSum(income)

printf("%f\n",SUM)

break

case '2':

SUM=paymentSum(payment)

printf("%f\n",SUM)

break

case '3':

double profit

SUM=incomeSum(income)

profit=SUM

printf("your income's sum is:")

printf("%f\n",SUM)

SUM=paymentSum(payment)

printf("your payment's sum is:")

printf("%f\n",SUM)

profit=profit - SUM

printf("your profit is:")

printf("%f\n",profit)

if(profit<=0)

{

printf("you shoule save money!!\n")

}

else

{

printf("you can spend your money as you like\n")

}

break

}

printf("*************************************************\n\n")

break

case '3':

system("pause")

exit(0)

}

}

return 0

}

//table initial

//链表初始化

NUM* initial()

{

NUM* money

money=(NUM*)malloc(sizeof(NUM))

money->n=0

money->next=money

return money

}

//build

//链表扩展

NUM* build(NUM* money)

{

NUM* temp

temp=(NUM*)malloc(sizeof(NUM))

temp->n=0

money->next=temp

temp->next=money

return temp

}

//input

//数据输入

void input(NUM* income,NUM* payment)

{

NUM* build(NUM* money)

printf("please choose what you want to enter:\n")

printf("1.income 2.payment\n")

char ch

NUM* temp1,*temp2

scanf("%c",&ch)

fflush(stdin)

temp1=income

temp2=payment

switch(ch)

{

case '1':

printf("please enter your income today:\n")

temp1=build(temp1)

scanf("%lf",&temp1->n)

fflush(stdin)

break

case '2':

printf("please enter your payment today:\n")

temp2=build(temp2)

scanf("%lf",&temp2->n)

fflush(stdin)

break

default :printf("enter ERROR!\n")

return

}

}

//output

//数据输出

void output(NUM* income,NUM* payment)

{

printf("please choose what you want to do\n")

printf("1.output all income 2.output all payment\n")

char ch

NUM *temp1,*temp2

scanf("%c",&ch)

temp1=income

temp2=payment

switch(ch)

{

case '1':

for(temp1!=incometemp1=temp1->next)

{

printf("%f",temp1->n)

}

break

case '2':

for(temp2!=paymenttemp2=temp2->next)

{

printf(" %f",temp2->n)

}

break

default :printf("output ERROR!\n")

}

printf("\n")

}

//income calculate

//收入计算(收入和支出在不同的链表中,同时处理要返回两个值,这不可能)

//可以用引用,但引用是C++里面有的,楼主要求是C,所以就不用引用了,而且引用一般出错率很高

double incomeSum(NUM* income)

{

double sum

NUM* temp

temp=income->next

sum=0

for(temp!=incometemp=temp->next)

{

sum=sum + temp->n

}

return sum

}

//payment calculate

//支出计算

double paymentSum(NUM* payment)

{

double sum

NUM* temp

temp=payment->next

sum=0

for(temp!=paymenttemp=temp->next)

{

sum=sum + temp->n

}

return sum

}

还有啥不明白的地方可以问我,写个程序不容易啊亲,满意请采纳,程序本身是不难写的,只是有点麻烦……

这个程序只能做到对数据的录入和输出,比较收入支出的大小,想要其它功能再说吧。

This is a completed finance app with Swift 3 And Nodejs.

The purpose i write it is i'm try to be a fullstack developer.

The ScreenShot as below

GitHub

Swift 3 + Realm + RxSwift + Alamofire

The project use Carthage as packmanager, please execute 'carthage update' before run

The project use npm &&MongoDB, please make sure you install it all before run

email: [email protected]

QQ: 550462 (pls comments: github)

CNode

MIT


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7975054.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存