主题:求零问题,求教
#include<iostream>
using namespace std;
int main()
{
double paid,income,dollar[]={100,50,10,5,2,1,0.5,0.2,0.1};
int i,change;
cout<<"客户购物金额:";
cin>>paid;
cout<<"实收:";
cin>>income;
paid=income-paid;
cout<<"应找客户金额为:"<<paid<<"元\n";
cout<<'\n';
for(i=0;i<9;i++)
{
change=paid/dollar[i];
cout<<dollar[i]<<"元="<<change<<"张\n";
cout<<'\n';
if(paid>=dollar[i])
paid=paid-change*dollar[i];
}
return 0;
}
请高手帮我看看这段代码,在计算的时候代码计算错误,我想了好久也想不处来,请教高手,谢谢啦!
using namespace std;
int main()
{
double paid,income,dollar[]={100,50,10,5,2,1,0.5,0.2,0.1};
int i,change;
cout<<"客户购物金额:";
cin>>paid;
cout<<"实收:";
cin>>income;
paid=income-paid;
cout<<"应找客户金额为:"<<paid<<"元\n";
cout<<'\n';
for(i=0;i<9;i++)
{
change=paid/dollar[i];
cout<<dollar[i]<<"元="<<change<<"张\n";
cout<<'\n';
if(paid>=dollar[i])
paid=paid-change*dollar[i];
}
return 0;
}
请高手帮我看看这段代码,在计算的时候代码计算错误,我想了好久也想不处来,请教高手,谢谢啦!