用do while 寫;
#include<stdio.h>
#include<stdlib.h>
int main(){
int pay , change , change1 , change2 , change3;
int coin , coin1 , coin2 , coin3 , k;
coin = 50;
coin1 = 10;
coin2 = 5;
coin3 = 1;
do{
printf("How much to pay:");
scanf("%d" , &pay);
change = pay / coin;
printf("50 coin has %d\n",change);
change1 = (pay%coin) / coin1;
printf("10 coin has %d\n",change1);
change2 = (pay%coin1) / coin2;
printf("5 coin has %d\n",change2);
change3 = (pay%coin2) / coin3;
printf("1 coin has %d\n",change3);
k = change + change1 + change2 + change3;
printf("Total coins has %d",k);
printf("\n\n");
}
while(k != 0);
return ;
}
似乎又更快了點
全站熱搜
留言列表