有没有大神能把下面的C++代码改成java代码 谢谢
#include<bits/stdc++.h>intmain(){std::stringarrString;std::getline(std::cin,arrString...
#include <bits/stdc++.h>
int main()
{
std::string arrString;
std::getline(std::cin, arrString);
std::vector<int> arr, dp;
std::stringstream sin(arrString);
for (int x; sin >> x; arr.emplace_back(x)) {}
dp.resize(arr.size(), arr[0]);
for (unsigned i = 1; i < dp.size(); dp[i] = std::min(dp[i - 1], arr[i]), ++i) {}
int ans = 0;
for (unsigned i = dp.size() - 1; i > 0; ans = std::max(ans, arr[i] - dp[i - 1]), --i) {}
std::cout << ans << std::endl;
return 0;
} 展开
int main()
{
std::string arrString;
std::getline(std::cin, arrString);
std::vector<int> arr, dp;
std::stringstream sin(arrString);
for (int x; sin >> x; arr.emplace_back(x)) {}
dp.resize(arr.size(), arr[0]);
for (unsigned i = 1; i < dp.size(); dp[i] = std::min(dp[i - 1], arr[i]), ++i) {}
int ans = 0;
for (unsigned i = dp.size() - 1; i > 0; ans = std::max(ans, arr[i] - dp[i - 1]), --i) {}
std::cout << ans << std::endl;
return 0;
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询