분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
옵션 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int show_list(); int input_money(); int input_choice(); int choice_money(int choice, int money, int add_money); int main() { int choice = 0; int money = 0; int add_money = 0; show_list(); money = input_money(); choice = input_choice(); choice_money(choice, money, add_money); } int show_list() { printf("1. Cola\t\t800won\n"); printf("2. Orange\t800won\n"); printf("3. Mountain\t1000won\n"); printf("4. Americano\t1500won\n"); printf("5. Strawberry\t2000won\n\n"); return 0; } int input_money() { int money = 0; printf("Put the money:"); scanf_s("%d", &money); return money; } int input_choice() { int choice = 0; printf("choice beverage:"); scanf_s("%d", &choice); return choice; } int choice_money(int choice, int money, int add_money) { int result = 0; if (choice == 1) { if (800 > money) { printf("Lack of money.\n"); int num = 0; while (1) { printf("Amount required : %d\n", 800 - money); num++; printf("Put the money:"); scanf("%d", &add_money); money = add_money + money; result = money; printf("Now money : %d\n", money); if (money >= 800) { printf("Cola\n"); result = money - 800; printf("Remainder Money: %d\n", result); } if (money >= 800) break; } } else { printf("Cola\n"); result = money - 800; printf("Remainder Money: %d\n", result); } } else if (choice == 2) { if (800 > money) { printf("Lack of money.\n"); int num = 0; while (1) { printf("Amount required : %d\n", 800 - money); num++; printf("Put the money:"); scanf("%d", &add_money); money = add_money + money; result = money; printf("Now money : %d\n", money); if (money >= 800) { printf("Orange\n"); result = money - 800; printf("Remainder Money: %d\n", result); } if (money >= 800) break; } } else { printf("Orange\n"); result = money - 800; } } else if (choice == 3) { if (1000 > money) { printf("Lack of money.\n"); int num = 0; while (1) { printf("Amount required : %d\n", 1000 - money); num++; printf("Put the money:"); scanf("%d", &add_money); money = add_money + money; result = money; printf("Now money : %d\n", money); if (money >= 1000) { printf("Mountain\n"); result = money - 1000; printf("Remainder Money: %d\n", result); } if (money >= 1000) break; } } else { printf("Mountain\n"); result = money - 1000; } } else if (choice == 4) { if (1500 > money) { printf("Lack of money.\n"); int num = 0; while (1) { printf("Amount required : %d\n", 1500 - money); num++; printf("Put the money:"); scanf("%d", &add_money); money = add_money + money; result = money; printf("Now money : %d\n", money); if (money >= 1500) { printf("Americano\n"); result = money - 1500; printf("Remainder Money: %d\n", result); } if (money >= 1500) break; } } else { printf("Strawberry"); result = money - 1500; } } else if (choice == 5) { if (2000 > money) { printf("Lack of money.\n"); int num = 0; while (1) { printf("Amount required : %d\n", 2000 - money); num++; printf("Put the money:"); scanf("%d", &add_money); money = add_money + money; result = money; printf("Now money : %d\n", money); if (money >= 2000) { printf("Strawberry\n"); result = money - 2000; printf("Remainder Money: %d\n", result); } if (money >= 2000) break; } } else { printf("Strawberry"); result = money - 2000; } } return result; } | cs |
죄송합니다. 댓글 작성은 회원만 가능합니다.