首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

(1.1.6)UVA 10978 Let's Play Magic!(直道式模拟)

2013-10-12 
(1.1.6)UVA 10978 Lets Play Magic!(直叙式模拟)/* * UVA_10978.CPP * *Created on: 2013年10月6日 *Autho

(1.1.6)UVA 10978 Let's Play Magic!(直叙式模拟)

/* * UVA_10978.CPP * *  Created on: 2013年10月6日 *      Author: Administrator */#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){char card[55][55],word[55][55],*order[55];int n;while(scanf("%d",&n)!=EOF,n){int i,j,k;for(i = 0 ; i < n ; ++i){order[i] = "?";}for(i = 0 ; i < n ; ++i){scanf("%s %s",&card[i],&word[i]);}for(i = 0,j = 0 ; i < n ; ++i){for(k = strlen(word[i]) ; ; j = (j + 1)%n ){if(order[j] == "?" && --k <= 0){break;}}order[j] = card[i];}for(i = 0 ; i < n ; ++i){printf(i < n - 1 ?"%s ":"%s\n",order[i],order[i] );}}}

热点排行