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 ...
随机推荐
- java8线程池创建并使用
1.创建@Configurationpublic class ThreadPoolConfig { /** * 创建线程池 */ @Bean(name = "threadPool" ...
- A - Yet Another Tetris Problem
A - Yet Another Tetris Problem 思路:判读一堆数字是不是同奇数偶数,写一个函数,循环遍历,然后判断是否同为奇数偶数. 代码: #include<iostream&g ...
- ubuntu20.04开机自动运行脚本实例
在 Ubuntu 20.04 中,/etc/rc.local 文件仍然存在,但不再默认启用,因为它已经被 systemd 代替.下面是使用systemd开机执行的脚本的实例: 1.编写脚本myscri ...
- 修改python下载镜像源
找到pip.ini(可能在"C:\Users\Administrator\AppData\Roaming\pip\pip.ini")→记事本打开→添加相应源 如果没有找到,在C:\ ...
- oracle ebs 账户组合验证
DECLARE l_segment1 GL_CODE_COMBINATIONS.SEGMENT1%TYPE; l_segment2 GL_CODE_COMBINATIONS.SEGMENT2%TYPE ...
- Kubernetes理论知识
一.k8s概念 Kubernetes(k8s)是跨主机集群的自动部署.扩展以及运行应用程序容器的开源平台,这些操作包括部署,调度和节点集群间扩展. master node:主节点 Master 是 C ...
- Vue项目在IE报错SCRIPT1003: 缺少' : ',导致页面空白的解决方案
一.问题 用IE浏览器访问系统,页面显示空白,控制台报错 SCRIPT1003: 缺少' : ' 二.查看报错 2.1.点击控制台报错,进入app.js,咋一看代码看不懂,不要慌,一直往 ...
- Centos 8 安装zabbix 爬坑
1.安装mininal 8 2.配置静态网络BOOTPROTO=staticIPADDR=192.168.2.1NETMASK=255.255.255.0GATEWAY=192.168.2.200DN ...
- Go实现KMP和Sunday算法
KMP 1 func KMP(str, substr string) int { 2 if substr == "" { 3 return 0 4 } 5 strLen := le ...
- android cannot generate view binders android.databinding.tool.util.LoggedErrorException
错误: Cannot resolve type 'viewModel'错误: cannot generate view binders android.databinding.tool.util.Lo ...