<pre class="objc" name="code"><pre class="objc" name="code">#include<stdio.h>
#define MAX 10
int main()
{
int lieshu,i,j;
double lamiantime,kaoroutime,yinliaotime,time,temp;
double timetotal[MAX];
char str[MAX][18];
printf("请输入现在队伍的列数:\n");
scanf("%d",&lieshu);
if(lieshu>MAX)
{
printf("输入错误!!!\n");
return 0;
}
printf("拉面的制作时间:\n");
scanf("%lf",&lamiantime);
printf("烤肉的制作时间:\n");
scanf("%lf",&kaoroutime);
printf("饮料的制作时间:\n");
scanf("%lf",&yinliaotime);
for(i=0;i<lieshu;)
{
printf("第%d对的排列情况:\n",i+1);
scanf("%s",str[i]); i++; }
for(i=0;i<lieshu;i++)
{
time=0;
for(j=0;str[i][j]!='\0';j++)
{
if(str[i][j]=='a'||str[i][j]=='A')
time+=kaoroutime+yinliaotime;
else if(str[i][j]=='b'||str[i][j]=='B')
time+=2*kaoroutime+2*lamiantime;
else if(str[i][j]=='c'||str[i][j]=='C')
time+=3*kaoroutime+3*lamiantime+3*yinliaotime;
else
{
printf("输入错误!!!\n");
return 0;
}
}
timetotal[i]=time;
}
for(i=0;i<lieshu;i++)
{
for(j=1;j<lieshu;j++)
{
if(timetotal[i]>timetotal[j])
{
temp=timetotal[i];
timetotal[i]=timetotal[j];
timetotal[j]=temp;
}
}
}
printf("鸣人所需最短时间:%.2lf\n",timetotal[0]);
return 0;
}
<pre class="objc" name="code"><pre class="objc" name="code">#include<stdio.h>
#define MAX 10
int main()
{
int lieshu,i,j;
double lamiantime,kaoroutime,yinliaotime,time,temp;
double timetotal[MAX];
char str[MAX][18];
printf("请输入现在队伍的列数:\n");
scanf("%d",&lieshu);
if(lieshu>MAX)
{
printf("输入错误!!!\n");
return 0;
}
printf("拉面的制作时间:\n");
scanf("%lf",&lamiantime);
printf("烤肉的制作时间:\n");
scanf("%lf",&kaoroutime);
printf("饮料的制作时间:\n");
scanf("%lf",&yinliaotime);
for(i=0;i<lieshu;)
{
printf("第%d对的排列情况:\n",i+1);
scanf("%s",str[i]); i++; }
for(i=0;i<lieshu;i++)
{
time=0;
for(j=0;str[i][j]!='\0';j++)
{
if(str[i][j]=='a'||str[i][j]=='A')
time+=kaoroutime+yinliaotime;
else if(str[i][j]=='b'||str[i][j]=='B')
time+=2*kaoroutime+2*lamiantime;
else if(str[i][j]=='c'||str[i][j]=='C')
time+=3*kaoroutime+3*lamiantime+3*yinliaotime;
else
{
printf("输入错误!!!\n");
return 0;
}
}
timetotal[i]=time;
}
for(i=0;i<lieshu;i++)
{
for(j=1;j<lieshu;j++)
{
if(timetotal[i]>timetotal[j])
{
temp=timetotal[i];
timetotal[i]=timetotal[j];
timetotal[j]=temp;
}
}
}
printf("鸣人所需最短时间:%.2lf\n",timetotal[0]);
return 0;
}