解题思路:
注意事项:
参考代码:
// 动态实现数组.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int time, sentance, speed_a, speed_2, speed_3;
int i;
cin >> time >> sentance >> speed_a >> speed_2 >> speed_3;
vector<char>post(sentance);
for (int i = 0; i < sentance; i++)
cin >> post[i];
vector<int>arr(sentance);
for(int j=0;j<sentance;j++){
int all_time = 0;
for(int i=0;i<=j;i++){
if (post[i] == 'u') {
all_time +=( speed_a+speed_3);
}
else if (post[i] == 'f'){
all_time += (speed_2+speed_2);
}
else
{
all_time +=( speed_3+speed_a);
}
}
arr[j] = all_time;
}
for ( i = 0; i < sentance; i++)
if (arr[i] > time)
break;
cout << i;
return 0;
}
0.0分
4 人评分
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:632 |
Pascal三角 (C语言代码)格式错误浏览:521 |
printf基础练习2 (有点不明白)浏览:845 |
淘淘的名单 (C语言代码)浏览:1104 |
【偶数求和】 (C语言代码)浏览:567 |
WU-链表数据求和操作 (C++代码)浏览:1317 |
WU-整除问题 (C++代码)浏览:612 |
printf基础练习2 (C语言代码)浏览:646 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:576 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:563 |