Created
December 17, 2014 04:20
-
-
Save Code-Hex/043bff03791b033bbf71 to your computer and use it in GitHub Desktop.
6-6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int money = 1000; /* 時給がこれくらいあったらいいのに... */ | |
int jikan; | |
float give_you_money; | |
printf("一週間に働いた時間を入力して\n"); | |
scanf("%d", &jikan); | |
jikan = jikan > 40 ? (jikan - 40) * 1.5 + 40 : jikan; | |
give_you_money = money * jikan; | |
printf("一週間分の君の給料: %d円\n", (int)give_you_money); | |
return 0; | |
} |
それはあるわ
@Code-Hex
あれ?「moneyとjikanはintなので、five_you_moneyをfloatにしなくてよい。」と思ったが笑
1.5倍するでしょう。
細かい時間になると答えが小数なるから一度floatにして、出力時にintでキャストのつもりだったけど、キャストがいらんな
あ。本当だw
時間給をKの願望じゃなくて任意の値にできたらいいかな(白い目)
scanf("%d",&money)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
いいね!
けど、five_you_moneyをfloatにする理由はあるのかな。