Minimum coin Exchange Issues
#include <iostream>#include<fstream>using namespacestd;intn,l;//an array of n-type coins L longintc[ -][ -];intt[ -];//Coin face valueintJisuan (intIintj);intMain () {FStream file ("2.1_input.txt");//This is the path to the file where the data needs to be read. FStream File2 ("2.1_output.txt");//This is the path to the file that needs to output the data. if(File.fail () | |File2.fail ()) {cout<<"The file open error!"<<Endl; } Else{file>>N; for(intI=1; i<=n;i++) {file>>T[i]; } File>>m; } intK; K=Jisuan (n,l); File2<<k<<Endl; return 0;}intJisuan (intIintj) { intmin; if((i==0)|| (j==0)) C[i][j]=0; if(i==1) { if(((1<=J) && (j<t[1]))|| ((t[1]<=J) && (j<=l) && (j%t[1]!=0)) ) C[i][j]= -; if(t[i]<=j) && (j<=l) && (j%t[i]==0)) C[i][j]=j/T[i]; } Else{min=jisuan (I-1, J); for(intX=j/t[i];x>0; x--) { intA=jisuan (I-1, J-x*t[i]) +x; if(min>a) Min=A; } C[i][j]=min; } returnc[i][j];}
C + + implements minimum coin exchange issues