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 ...
随机推荐
- Mysql 字符集的设置和修改
Show variables like 'character%'; //显示目前mysql默认 字符集 显示数据连接字符集 修改字符集 D:\mysql>Net stop mysql // ...
- Spring 的XML配置文件中提示的配置
1.看图:2.关于web.xml配置文件提示(1)下载(保存)http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd文件.(2)在eclipse中 Window ...
- AMBA-AXI学习笔记
transfer与transaction的区别: transfer是只需要一次Valid和Ready握手的单次信息交换过程. transaction是一次完整的突发传输,包括地址transfer,一个 ...
- 直播平台搭建源码,canvas 画一条波浪线 进度条
直播平台搭建源码,canvas 画一条波浪线 进度条 <template> <view> <canvas :style="{'width': width ...
- [笔记] 什么是Groovy?什么是Kotlin?
关于Groovy 参考文章 https://www.w3cschool.cn/groovy/ 摘抄如下: Groovy是JVM的一个替代语言(替代是指可以用 Groovy 在Java平台上进行 Jav ...
- 制作win10装机U盘
第一步:准备一个8G容量以上的U盘 第二步:制作系统盘. 进入windows官网 官网win10下载地址:https://www.microsoft.com/zh-cn/software-downlo ...
- [Oracle19C 数据库管理] 加载和传输数据库
移动数据的通用架构 数据泵data pump(impdp, expdp),借助DBMS_DATAPUMP存储过程,可以进行表的导出导入,行记录的导出导入,表空间的导出导入或者整个schema的导出导入 ...
- mac Big Sur 安装MAT
1.下载MAT,https://www.eclipse.org/mat/previousReleases.php,这里安装最新版本1.12.0版本,这个依赖jdk11,需要安装openjdk11,请前 ...
- J V M(二)双亲委派机制及native
package java.lang;public class String {// 双亲委派机制: 安全// 应用程序加载器-扩展程序加载器-根加载器// 自底向上检查类是否被加载,自顶向下加载类// ...
- gitlab+jenkins配置自动触发构建
1.jenkins安装gitlab插件 2.启动gitlab容器 docker run -itd -v /opt/gitlab/etc:/etc/gitlab -v /opt/gitlab/log:/ ...