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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

记账类问题汇总

發布時間:2025/4/16 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记账类问题汇总 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

(注:暫時先記錄這些問題,后期會持續更新)

1,用函數實現財務現金記賬

#include<stdio.h> float cash; //定義全局變量,保存現金余額 int main(void) {int choice;float value;void income(float number),expend(float number); //函數聲明 cash = 0;printf("Enter operte choice(0--end,1--income,2--expend):");scanf("%d",&choice); //輸入操作類型while(choice != 0){if(choice == 1||choice == 2){printf("Enter cash value:"); //輸入操作現金額 scanf("%f",&value);if(choice == 1)income(value); //計算現金收入 elseexpend(value); //計算現金輸出printf("current cash:%.2f\n",cash); }printf("Enter operte choice(0--end,1--income,2--expend):");scanf("%d",&choice); //繼續輸入操作類型 } return 0; } void income(float number) {cash = cash + number; //改變全局變量cash }void expend(float number) {cash = cash - number; }

?

?

2,用函數實現餐廳記賬

#include<stdio.h> float total = 0.0; short count = 0; short tax_percent = 6; float add_with_tax(float f) //返回一小筆金額 {float tax_rate = 1 + tax_percent / 100.0; //有了.0,計算就會以浮點數進行,否則表達式會返回整數total = total + (f * tax_rate);count = count + 1;return total; } int main() {float val;printf("Price of item:");while(scanf("%f",&val)==1){printf("Total so far:%.2f\n",add_with_tax(val));printf("Price of item:");}printf("\nFinal total:%.2f\n",total);printf("Number of items:%hi\n",count);return 0; }

?

總結

以上是生活随笔為你收集整理的记账类问题汇总的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。