UVa1584——Circular Sequence
2015-09-20 15:18
302 查看
题目很简单。直接暴力过。求解字典序最小的字符串。
下面的是AC的代码:
下面的是AC的代码:
#include <iostream> #include <cstring> using namespace std; int main() { int t, i, j, k; char str[110]; char temp[110], ans[110]; while(cin >> t) { while(t--) { cin >> str; int length = strlen(str); strcpy(ans, str); for(i = 1; i < length; i++) { k = 0; for(j = i; j < length; j++) temp[k++] = str[j]; for(j = 0; j < i; j++) temp[k++] = str[j]; temp[k] = '\0'; if(strcmp(temp, ans) < 0) strcpy(ans, temp); } cout << ans << endl; } } return 0; }
相关文章推荐
- 23设计模式之建造者模式(Builder)
- Android Gradle 构建工具(Android Gradle Build Tools)是什么?
- 如何把一个UITableView滚动到tableFooterView?
- ios9兼容系列之解决iPad提交报错“iPad Multitasking support requires launch story board in bundle '”
- Mycat全局Sequence详解
- Maven打包web项目报错Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if
- Android UI高级控件之SimpleAdapter
- 徒手用Java来写个Web服务器和框架吧<第二章:Request和Response>
- 在UIButton中如何将imageView和titleView居中且上下分布
- android 事件处理机制之requestDisallowInterceptTouchEvent
- 使用Libcef+Duilib创建自己的Chrome内核浏览器
- Minor issue about class define and the valid scope of scope operator
- iOS:搜索栏控件UISearchBar and SearchDisplayController的使用
- IOS基础UI之(五)UIAlertView、UIActionSheet和UIAlertController详解
- JAVA基础学习(十三)--String、StringBuilder、StringBuffer与包装类
- UIMenuController的使用,对UILabel拷贝以及定制菜单
- A014-values资源
- UCGUI使用外部字库芯片显示汉字
- poj 2031--Building a Space Station(prim)
- poj 2031--Building a Space Station(prim)