货币兑付

来源:互联网 发布:手机gif编辑软件 编辑:程序博客网 时间:2024/04/29 19:04
#include<iostream>#define N4using namespace std;int main(){int s = 0, n,A[N] = { 25, 10, 5, 1 };int * p=new int[N];cout<<"输入所需支付的货币钱数n为:";cin>>n;for(int i=0;i<N;i++){p[i]=0;while((s+=A[i])<=n)p[i]++;s-=A[i];}cout<<"支付"<<n<<"分钱需要:";for(int j=0;j<N;j++)cout<<p[j]<<"张"<<A[j]<<"分的 ";cout<<endl<<endl;system("pause");return 0;}

0 0
原创粉丝点击