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 ...
随机推荐
- Spring 自定义注解 操作日志
1.自定义注解 package com.jay.demo3.aop1.myannotation; import java.lang.annotation.Documented; imp ...
- 2018GPLT
2018GPLT 7-1 天梯赛座位分配 一共有n所学校参加比赛,每所学校有\(a_i\)只队伍,每只队伍共10人,要保证每个学校的所有队员不能相邻就坐,令每一所学校的队伍排成一排纵列,然后从第一所学 ...
- JAVA学习笔记-10
String类: 字符串是一个特殊的对象.字符串最大的特点:一旦被初始化就不可以被改变. String类适用于描述字符串事物.那么它就提供了多个方法对字符串进行操作. 常见的操作: 1.获取: int ...
- OCR接口
OCR基础框 import pytesseract from PIL import Image img = Image.open('实际数据1.jpeg') #具体位置截图 image1 = Imag ...
- 静态变量设为non-public或者加final关键字
Class variable fields should not have public accessibility Vulnerability Minor Main sources cwe Avai ...
- mi
小米耳机页面 <style> * { margin: 0; padding: 0; } body { width: 1226px; background-color: #f5f5f5; m ...
- tp5上传图片常规
前端不多说,就是使用input标签的file格式. tp5用request()->file('input的名字')接收图片,是binary格式的数据: $file = request()-> ...
- 解决 Outlook 的 Teams 会议加载项ID/链接等问题
参考: https://learn.microsoft.com/zh-cn/microsoftteams/troubleshoot/meetings/resolve-teams-meeting-add ...
- Web开发 学习 调试 调优
目录 快捷操作 调试方法 基本调试方法 修改参数和请求重发 Chrome抓包分析 性能优化 安全 cURL请求 参考 参考:MDN 调试HTML 参考:什么是浏览器开发者工具? 参考:检查和编辑页面与 ...
- java技术系列(一) Enum
Enum的本质是类,继承自Enum类. enum直接使用==进行比较就可以. 类型的静态values方法,返回左右的枚举实例. ordinal方法返回enum声明中枚举常亮的位置. enum可以继承接 ...