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

歡迎光臨散文網(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ǔ)快速入門教程的評論 (共 條)

分享到微博請遵守國家法律
保定市| 九寨沟县| 河津市| 永胜县| 石阡县| 马龙县| 尼木县| 西青区| 凯里市| 昌乐县| 车致| 嘉祥县| 加查县| 白水县| 新巴尔虎左旗| 自治县| 方城县| 交城县| 余庆县| 迁安市| 日土县| 甘德县| 科技| 河东区| 新余市| 新闻| 三明市| 长垣县| 科尔| 亳州市| 泗水县| 微博| 九寨沟县| 祁阳县| 南宫市| 康乐县| 冀州市| 陆丰市| 东安县| 会泽县| 盘锦市|