高分悬赏c语言大学生记账程序的实现,急急急!!!在线等~~~
1、能够完成收支的记录2、能够进行财务预警3、简单的财务分析c语言编写哦。。可以运行。。求代码。。谢谢啦。。...
1、能够完成收支的记录
2、能够进行财务预警
3、简单的财务分析
c语言编写哦。。可以运行。。求代码。。谢谢啦。。 展开
2、能够进行财务预警
3、简单的财务分析
c语言编写哦。。可以运行。。求代码。。谢谢啦。。 展开
展开全部
#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!=income;temp1=temp1->next)
{
printf("%f",temp1->n);
}
break;
case '2':
for(;temp2!=payment;temp2=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!=income;temp=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!=payment;temp=temp->next)
{
sum=sum + temp->n;
}
return sum;
}
还有啥不明白的地方可以问我,写个程序不容易啊亲,满意请采纳,程序本身是不难写的,只是有点麻烦……
这个程序只能做到对数据的录入和输出,比较收入支出的大小,想要其它功能再说吧。
#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!=income;temp1=temp1->next)
{
printf("%f",temp1->n);
}
break;
case '2':
for(;temp2!=payment;temp2=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!=income;temp=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!=payment;temp=temp->next)
{
sum=sum + temp->n;
}
return sum;
}
还有啥不明白的地方可以问我,写个程序不容易啊亲,满意请采纳,程序本身是不难写的,只是有点麻烦……
这个程序只能做到对数据的录入和输出,比较收入支出的大小,想要其它功能再说吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询