林催催


私信TA

用户名:007seven

访问量:1766

签 名:

等  级
排  名 51527
经  验 242
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校 山西大学
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

// 动态实现数组.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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区