hdu 5427 A problem of sorting
来源:互联网 发布:ubuntu安装虚拟机 编辑:程序博客网 时间:2024/05/16 07:17
点击打开链接
题目大意:就是让你排序,按照从大到小排序,然后输出姓名就行了
解题思路:注意这里有一个坑,就是可能有空格作为当前的名字比如说: ITAK,输出的时候也需要输出空格,这就需要用到cin.getline了,这个就是能读单字符的。。。
读入啥,输出啥,可以手动实现一下:
上代码:
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">/*Date : 2015-09-05 晚上Author : ITAKINGMotto :今日的我要超越昨日的我,明日的我要胜过今日的我;以创作出更好的代码为目标,不断地超越自己。*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cstdio>using namespace std;struct sa{ char name[105]; int date;} arr[105];int cmp(sa a, sa b){ return a.date > b.date;}char str[200];int main(){ int t,m; scanf("%d",&t); while(t--) { cin>>m; getchar(); for(int i=0; i<m; i++) { cin.getline(str,200);//能够正常读入单字符 int len = strlen(str); arr[i].date = str[len-4]*1000+str[len-3]*100+str[len-2]*10+str[len-1]; len -= 5; str[len] = '\0'; strcpy(arr[i].name,str); } sort(arr, arr+m, cmp); for(int i=0; i<m; i++) cout<<arr[i].name<<endl; } return 0;}
0 0
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- HDU 5427 A problem of sorting 水题
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting
- HDU 5427 A problem of sorting
- HDU 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- hdu 5427 A problem of sorting(水)
- hdu 5427 A problem of sorting 解题报告
- HDU 5427-A problem of sorting(字符串处理)
- 【map容器+string】hdu 5427 A problem of sorting
- HDU——5427 A problem of sorting
- A problem of sorting
- HDOJ 5427 A problem of sorting
- HDU 5431/BC 54A A problem of sorting
- HDU5429----A problem of sorting
- HDU 5427 A problem of sorting(字符串处理+排序)——BestCoder Round #54(div.2)
- 小假期(接口那些事)
- const在c++中的用法分析
- <context:component-scan>使用说明
- 一次完整的HTTP事务是怎样一个过程?
- 1.OC第一个工程,类的设计,重构方法,构造函数
- hdu 5427 A problem of sorting
- Android列表ListView控件的使用
- HDU 3652 B-number (数位dp)
- error: declaration may not appear after executable statement in block
- arm的2级页表在Linux内核创建过程解析
- c语言学习之顺序结构
- python 学习笔记(=)
- Servlet+JSP+JavaBean开发模式(MVC)介绍
- (转) 安卓实现parcelable接口作用