UVa 482 - Permutation Arrays
来源:互联网 发布:巩俐白骨精知乎 编辑:程序博客网 时间:2024/05/21 11:33
题目:给你两组数字,第一组是编号,第二组是值,按第一组的编号输出第二组的值。
分析:简单题、输入输出控制。读入数据,利用编号排序输出即可。
说明:注意数据范围,数组开大点。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstdio>using namespace std;typedef struct noded{int id;char str[101];}dnode;dnode D[100001];bool cmp( dnode p, dnode q ){return p.id < q.id;}int main(){int n;char buf[101];while ( scanf("%d",&n) != EOF ) while ( n -- ) {getchar();getchar();int count = 0,move = 0;while ( 1 ) {buf[move] = getchar();if ( buf[move] == '\n' ) break;if ( buf[move] == ' ' ) {if ( move ) {buf[move] = 0;D[count ++].id = atoi( buf );move = 0;}}else move ++;}buf[move] = 0;D[count ++].id = atoi( buf );for ( int i = 0 ; i < count ; ++ i )scanf("%s",D[i].str);sort( D, D+count, cmp );for ( int i = 0 ; i < count ; ++ i )printf("%s\n",D[i].str);if ( n ) printf("\n");}return 0;}
0 0
- UVa 482 - Permutation Arrays
- uva-10252-Common Permutation
- UVa 10252 Common Permutation
- uva 10252Common Permutation
- UVA 11027 Palindromic Permutation
- Uva 10252 - Common Permutation
- Uva-11525-Permutation
- UVA 11525 Permutation
- UVA - 11027 Palindromic Permutation
- UVa 10252 - Common Permutation
- uva 11525 Permutation
- UVA - 11525 Permutation
- Uva 11525 Permutation
- uva 11027 Palindromic Permutation
- UVA - 1485 Permutation Counting
- uva 11922 - Permutation Transformer
- uva 11922 Permutation Transformer
- uva - 11525 Permutation
- 常用开源服务器库和中间件
- Java比较汉字字符串排序与C++比较汉字排序
- 图片轮播
- [LeetCode]Insertion Sort List
- thinkphp中的F方法
- UVa 482 - Permutation Arrays
- 搭建手机网站
- struts2的validate在使用过程中的一个问题
- ThinkPHP的I方法
- 省赛总结---哈工大(威海)
- A、D、S、L、C、F、I
- thinkphp中的时间戳,获取完整URL,
- 微村:做APP里的掌上村长
- jq缩放图片与js获取屏幕分辨率