?? coinmain.cpp
字號(hào):
#include <stdio.h>
#include "SortFun.h"
int main()
{
int i;
double money; /*the money need to be changed */
double lastmoney; /* when change happen,the money last*/
double coin[3]={0.5,0.2,0.1}; /* the coin array */
int coincnt[3]={0,0,0}; /* the count per coin */
/********************************
We can get our own coin array without order.
Then using a bubble sort to reorder it to big-small.
Suppose dimension is N.
printf("Input your coin:\n");
for(i=0;i<N;i++)
scanf("%lf",coin[i]);
bubblesort(coin,N);
*****************************************/
printf("Please input the money you want to change!\n");
scanf("%lf",&money);
lastmoney=money;
for(i=0;i<3;i++) /* for per coin,count its number untill lowwer than lastmoney*/
{
while(lastmoney>=coin[i])
{
printf("\n%2f,%2f",lastmoney,coin[i]);
coincnt[i]++;
lastmoney-=coin[i];
}
}
for(i=0;i<3;i++)
printf("\n%lf——%d",coin[i],coincnt[i]);
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -