ZSTUOJ刷题⑩:Problem B.--零起点学算法103——查找最大元素
Problem B: 零起点学算法103——查找最大元素
Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 9951 Solved: 4793
Description
Input
Output
Sample Input
abcdefgfedcba
xxxxx
Sample Output
abcdefg(max)fedcba
x(max)x(max)x(max)x(max)x(max)
代码如下:
#include<bits/stdc++.h>
using namespace std; int main(){
char a[101];
while(gets(a)!=NULL){
vector<char> b;
vector<char> c;
for(int i=0;i<(int)strlen(a);i++){
b.push_back(a[i]);
c.push_back(a[i]);
}
sort(b.begin(),b.end());
int max=b[(int)strlen(a)-1];
for(int i=0;i<strlen(a);i++){
cout<<c[i];
if(c[i]==max) cout<<"(max)";
}
cout<<endl;
} return 0;
}
这里要注意不能直接写成strlen(),要写成(int)strlen(),具体理解可以看看这篇文章https://blog.csdn.net/liujian20150808/article/details/50406601
ZSTUOJ刷题⑩:Problem B.--零起点学算法103——查找最大元素的更多相关文章
- Problem H: 零起点学算法103——查找最大元素
#include<stdio.h> #include<string.h> int main() { ]; while(gets(a)!=NULL) { ]; ;a[i]!='\ ...
- Problem H: 零起点学算法109——单数变复数
#include <stdio.h> #include<string.h> int main(void) { int n; ]; scanf("%d",&a ...
- Problem G: 零起点学算法106——首字母变大写
#include<stdio.h> #include<string.h> int main(void) { ]; int i,k; while(gets(a)!=NULL) { ...
- Problem D: 零起点学算法95——弓型矩阵
#include<stdio.h> #include<string.h> int main() { ][]; while(scanf("%d%d",& ...
- Problem F: 零起点学算法42——多组测试数据输出II
#include<stdio.h> int main() { ; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { ...
- Problem E: 零起点学算法34——3n+1问题
#include<stdio.h> #include<math.h> int main() { int n; n<=pow(,); ; scanf("%d&qu ...
- Problem K: 零起点学算法107——统计元音
#include<stdio.h> int main() { int n; ]; while(scanf("%d%*c",&n)!=EOF) { while(n ...
- Problem J: 零起点学算法105——C语言合法标识符
#include<stdio.h> #include<ctype.h>//调用isalpha函数 int main() { int n; ]; while(scanf(&quo ...
- Problem I: 零起点学算法104——Yes,I can!
#include<stdio.h> int main() { ]; while(gets(a)!=NULL) { printf("I am "); printf(&qu ...
- Problem G: 零起点学算法102——删除字符
#include<stdio.h> #include<string.h> int main() { ],a; while(gets(ch)!=NULL) { scanf(&qu ...
随机推荐
- 推荐一个 python学习网站
kaggle python课程: https://www.kaggle.com/learn/python 知乎有个博主在专栏放了课程的中文版: https://www.zhihu.com/people ...
- docker+react+nginx部署
一.准备工作 1.先确保项目可以正常运行. 2.如果拉代码到Linux下进行打包,注意node版本,我就是版本不同,yarn build一直不成功. 3.找一个nginx的配置文件nginx.conf ...
- axios和ajax对响应是文件流用blob处理
先看axios请求处理,下载文件 this.$axios.get(api.exportMortgageOrderExcelVisit, { params: params, responseType: ...
- 【ubuntu20】解压文件
第一类处理 *** .zip或 ***.rar 时,需要先下载相对应的unzip和unrar,可在终端,执行 sudo apt-get install unzipsudo apt-get instal ...
- Django操作mongo数据库二(MongoClient方式)
一.基本环境 1.开发环境: Python环境:Python 3.8.16 Django环境:4.1 2.需要安装的包 pip install pymongo pip install mongoeng ...
- EMQX+阿里云飞天洛神云网络 NLB:MQTT 消息亿级并发、千万级吞吐性能达成
随着物联网技术的发展与各行业数字化进程的推进,全球物联网设备连接规模与日俱增.一个可靠高效的物联网系统需要具备高并发.大吞吐.低时延的数据处理能力,支撑海量物联网数据的接入与分析,从而进一步挖掘数据价 ...
- C++ primer 5th 第二章 变量和基本类型 阅读笔记
第二章 变量和基本类型 第一节 基本内置类型 C++标准规定了算术类型尺寸的最小值,同时允许编译器赋予这些类型更大的尺寸. 比如: 类型 含义 最小尺寸 bool 布尔类型 未定义 wchar_t 宽 ...
- Spring Web MVC注解
@RequestMapping @RequestMapping注解的主要用途是将Web请求与请求处理类中的方法进行映射. Spring MVC和Spring WebFlux都通过RquestM ...
- BIP查询框添加查询条件
// 搜索框添加查询条件 viewModel.on("afterMount", function (data) { let agentId = viewModel.getParam ...
- https代理服务器(四)java动态签发【失败】
https://zhuanlan.zhihu.com/p/355241710?utm_id=0 http://t.zoukankan.com/xiaxj-p-8961131.html https:// ...