最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

尚硅谷C語言零基礎(chǔ)快速入門教程

2023-08-02 17:16 作者:writer  | 我要投稿

#include <stdio.h>

#include <stdlib.h>

#include <string.h>


//1.解決一個(gè)問題,目前沒有數(shù)據(jù)庫,應(yīng)該使用數(shù)結(jié)構(gòu)體賴保存數(shù)據(jù),才能達(dá)到效果

//2.

typedef struct Income{

double money;

char* state;

char* king;

double sum;

struct Income *next;

}Income;


Income* init(){ //初始化

Income* income = (Income*)malloc(sizeof(Income));

income -> money = 0.0;

income -> state = "";

income -> king = "";

income -> sum = 0.0;

income -> next = NULL;

return income;

}



void Income_init(Income* income,double data,char string[]){ //收入

//創(chuàng)建一個(gè)登錄收入結(jié)構(gòu)體需要多大的空間

double k = 0.0;

Income* node = (Income*)malloc(sizeof(Income));

node -> money = data;??//賦值

node -> state = string;?//賦值(地址)

node -> king = "收入";

k = income -> sum;

k += data;

node -> sum = k;

income -> sum = k;

node -> next = income -> next;

income -> next = node;

}


void expend_init(Income* income,double data,char string[]){ //支出

//創(chuàng)建一個(gè)登錄收入結(jié)構(gòu)體需要多大的空間

double k = 0.0;

Income* node = (Income*)malloc(sizeof(Income));

node -> money = data;??//賦值

node -> state = string;?//賦值

node -> king = "支出";

k = income -> sum;

k -= data;

node -> sum = k;

income -> sum = k;

node -> next = income -> next;

income -> next = node;

}



void forprint(Income* income){//明細(xì)

income = income -> next;

printf("————————當(dāng)前收支明細(xì)記錄————————\n");

printf("收支\t\t收支金額\t說明\t賬號金額\n");

while(income){

printf("%s\t\t%.2f\t\t%s\t\t%.2f\n",income -> king,income -> money,income -> state,income -> sum);

income = income -> next;

}

printf("\n");

}




void main(){

int tmp = 0;

double kl = 0; //金額

char name[30];

char turn = ' ';

Income* income = init();

while(1){

printf("————————家庭收支記賬軟件————————\n");

printf("\t\t1 收到明細(xì)\n");

printf("\t\t2 登錄收入\n");

printf("\t\t3 登錄支出\n");

printf("\t\t4 退??出\n");


printf("請選擇(1-4):");

scanf("%d",&tmp);

if(tmp == 2){//添加金額

printf("本次收入金額:");

scanf("%lf",&kl);

printf("本次收入說明:");

scanf("%s",name);

Income_init(income,kl,name);

}else if(tmp == 1){ //顯示明細(xì)

forprint(income);

}else if(tmp == 4){ //退出

getchar();

printf("\n確認(rèn)是否退出(Y/N):");

scanf("%c",&turn);

if(turn == 'Y' || turn == 'y'){

break;

}else if(turn == 'N' || turn == 'n'){

continue;

}else{

printf("請輸入有效值?。。n");

}

}else if(tmp == 3){//支出

printf("本次支出金額:");

scanf("%lf",&kl);

printf("本次支出說明:");

scanf("%s",name);

expend_init(income,kl,name);

}

}


getchar();


getchar();

}






尚硅谷C語言零基礎(chǔ)快速入門教程的評論 (共 條)

分享到微博請遵守國家法律
上高县| 蓬莱市| 清水县| 无极县| 双桥区| 怀仁县| 武强县| 报价| 林芝县| 松潘县| 确山县| 上饶县| 锡林郭勒盟| 外汇| 德昌县| 赣州市| 手游| 海南省| 达拉特旗| 纳雍县| 吴桥县| 海晏县| 鱼台县| 龙胜| 汝城县| 西青区| 博罗县| 武清区| 宣武区| 即墨市| 永仁县| 锡林浩特市| 剑川县| 平山县| 嘉峪关市| 诸暨市| 保靖县| 楚雄市| 财经| 靖边县| 新竹市|