SRM 583 Div II Level One:SwappingDigits
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12609
#include <iostream>
#include <string> using namespace std; string minstr = ""; class SwappingDigits
{
public: string minNumber(string num);
}; string SwappingDigits::minNumber(string num)
{
string temp;
string mins = "";
for (int i = 0; i < num.size()-1; i++) {
for (int j = i+1; j < num.size(); j++) {
temp = num;
swap(temp[i], temp[j]);
if (temp[0] != '0' && mins == "") {
mins = temp;
} else {
if (temp[0] != '0' && temp < mins) {
mins = temp;
}
}
}
} return mins;
}
SRM 583 Div II Level One:SwappingDigits的更多相关文章
- SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 用Dijkstra实现,之前用Floyd算法写了一个, ...
- SRM 582 Div II Level One: SemiPerfectSquare
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12580 比较简单,代码如下: #include <ios ...
- SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意 ...
- SRM 223 Div II Level Two: BlackAndRed,O(N)复杂度
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3457&rd=5869 解答分析:http://comm ...
- SRM 207 Div II Level Two: RegularSeason,字符串操作(sstream),多关键字排序(操作符重载)
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=2866&rd=5853 主要是要对字符串的操作要熟悉,熟 ...
- SRM 582 Div II Level Two SpaceWarDiv2
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 #include <iostream> # ...
- SRM 219 Div II Level One: WaiterTipping,小心约分
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12609&rd=15503 这题目看上去so easy, ...
- SRM 212 Div II Level One: YahtzeeScore
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=1692&rd=5858 比较简单. 代码如下: #inc ...
- SRM 212 Div II Level Two: WinningRecord,Brute Force
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3003&rd=5858 比较简单. 代码如下: #inc ...
随机推荐
- 利用VC助手(VA)添加注释
利用VC助手(VA)添加注释 今天想给自己写的代码加上版权信息,同时整理一下代码的注释.但是为了保持同样的格式,总是copy,显得有些繁琐.然后试图找解决方案.我用的是VS 2010, 刚开始是尝试了 ...
- [Swust OJ 166]--方程的解数(hash法)
题目链接:http://acm.swust.edu.cn/problem/0166/ Time limit(ms): 5000 Memory limit(kb): 65535 有如下方程组: A1 ...
- 使用Qt设计师文件的3种方式
使用Qt设计师设计的.ui界面文件是XML文件,有3种方式在PyQt中使用,本文将通过实例进行讲解. 使用PyQt中如何结合Qt设计师进行开发中的例子.点击按钮修改标签的内容. 1. 直接使用ui文件 ...
- The Hungarian algorithm Template
The Hungarian algorithm with The adjacency matrix : 计算最大匹配问题 int n1, n2, m, ans; int res[MAXN]; bool ...
- 【集训笔记】归纳与递推【HDOJ1297
例:(2050)折线分割平面 问题描述: 平面上有n条折线,问这些折线最多能将平面分割成多少块? 样例输入 1 2 样例输出 2 7 平面上有n条折线,问这些折线最多能将平面分割成多少块? 解: 折线 ...
- Java, C#, Swift语法对比速查表
原文:Java, C#, Swift语法对比速查表 Java 8 C# 6 Swift 变量 类型 变量名; 类型 变量名; var 变量名 : 类型; 变量(类型推断) N/A var 变量名= ...
- Clojure学习05:谓词函数
谓词函数是一个判断式,一个返回bool值的函数. clojure中(lisp习惯)有个规定:对于判断功能的函数,函数名后面都有一个“?”号.所以只要看到后面带问号的函数名,就知道这一定是一个判断函数. ...
- matlab绘图方法汇总
Matlab画图 强大的画图功能是Matlab的特点之中的一个,Matlab提供了一系列的画图函数,用户不须要过多的考虑画图的细节,仅仅须要给出一些基本參数就能得到所需图形,这类函数称为高层画图函数. ...
- 非确定有限状态自动机的构建(二)——将CharVal转换为NFA
保留版权,转载注明出处:潘军彪的个人博客(http://blog.csdn.net/panjunbiao/article/details/9378933) 将上下文无关文法读入内存之后,可以将它转换成 ...
- 工作随记 warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
错误信息:F:\BUILD\IDS7020\trunk\manage_src\dev\java_src\tds7030-web\Ant\build.xml:344: warning: 'include ...