C++第二版4--29:用100元买100支笔,单价:钢笔3元,圆珠笔2元,铅笔0.5元 问:各买多少支(每种笔至少一只) #include<iostream.h> int main() { int money,num,i,j,k; double p1,p2,p3; cout<<"Please input the money ,the totle number,the each kind of price:"<<endl; while(cin>>money>>num>>p1>>p2>>p3) { int a,b,c; a=money/p1; b=money/p2; c=money/p3; for(i=1;i<=a;i++) { for(j=1;j<=b;j++) { for(k=1;k<=c;k++) { if(p1*i+p2*j+p3*k==money&&i+j+k==num) cout<<"need p1's number is:"<<i<<endl <<"need p2's number is:"<<j<<endl <<"need p3's number is:"<<k<<endl <<endl; } } } } return 0; }