[C] 纯文本查看 复制代码
#include<cstdio> using namespace std;
double rate[6][6];
int country[15];
int main()
{
int t,n;
for(int i = 1;i <= 5;i++)
for(int j = 1;j <= 5;j++)
scanf("%lf",&rate[j]);
double money;
while(scanf("%d",&n) && n != 0)
{
country[n+2] = 1;
country[1] = 1;
for(int i = 2;i <= n + 1;i++)
scanf("%d",&country);
scanf("%lf",&money);
for(int i = 1;i <= n + 1;i++)
{
money *= rate[country][country[i+1]];
money = (int)(money*100 + 0.5); //每次交换都应该进行百分位的四舍五入 money /= 100;
}
printf("%.2lf\n",money);
}
}