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 ...
随机推荐
- slitaz5安装vim,sakura终端命令行打不开
刚开始安装了vim后,vim提示libtinof.so.6打不开.在网上查,发现可能是库缺少.然后查看了依赖库文件 ldd /usr/bin/vim 发现果然缺少了 libncurses.so.6 的 ...
- Maven简答题
1.什么是Maven? 自动化构建工具,专注服务于Java平台的项目构建和依赖管理 2.使用Maven的好处以及原因? (1)大量的jar包反复复制,造成冗余.使用Maven后每个jar包只在本地仓库 ...
- solve--NAT模式下配置静态IP地址
第一步 打开虚拟机的虚拟网络编辑器:
- [转]Windows 批处理命令教程
第一章 批处理基础 第一节 常用批处理内部命令简介 批处理定义:顾名思义,批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT或者CMD.这些命令统称批处理命令.小知识:可 ...
- MyBatis_01(前置知识)
1-学习思路(课程主要内容): 2-MyBatis特性 3- MyBatis下载 但是我们在使用MyBatis的时候,都是直接 "Maven导入MyBatis的jar包" (所以, ...
- linux 动态库、静态库
库:可执行的二进制代码,不可以独立执行(没有main函数入口) 库是否兼容:取决于编译器.汇编器.链接器 linux链接静态库(.a):将库中用到的函数的代码指令,写入到可执行文件中.运行时无依赖 l ...
- how to make the windows console works with utf-8 encoded project
the console of the windows os is not working in the utf-8 encoding, by default. When you force your ...
- C++ STL摘记
一.string类补充 1.函数示例: (1)find和rfind函数,返回的是下标或者string::npos index=ss.find(s1,pos,num) find从pos(包括)开始往右查 ...
- C# 中 SetTimeout 方案
近期项目中需在用户点击按钮后,延时执行代码逻辑,避免频繁操作.网上没找到有关 C# SetTimeout 官方API , 于是通过异步线程,动手实现一个.方案如下,如果同一个DelayedProces ...
- matlab判断操作
类型判断 1.查看变量类型时可用class,判断某变量的类型值:会生成0或1,1-匹配,0-不匹配 isa(Data,'double') isa(Data,'cell') 2.也可用如下. strcm ...