poj 2469 Stack 'em Up
最近做挑战编程,题目难度加大,题意理解也越来越吃力了,好几次都理解错题意。
题意:先给出洗牌者能够洗牌的几种方法,再给你k,让你求他经过第k种方法洗牌后的排序
理解:每次下面给出的k使每一次都重新洗一次,而不是让你输出第k组数据
#include<stdio.h> int main() { int n,k,i,a,j; char str[15][10]= {"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"}; int t[110][110];//储存的命令 int save[110][60]; scanf("%d",&n); for (i=1; i<=52; i++) save[0][i]=i; for (i=1; i<=n; i++) for (j=1; j<=52; j++) scanf("%d",&t[i][j]); while(scanf("%d",&a)!=EOF) { for (i=1; i<=52; i++) { //i是位置j,t[i]整数i save[a][i]=save[0][t[a][i]]; } for (i=1;i<=52;i++) { save[0][i]=save[a][i]; } for (i=1; i<=52; i++) { //printf("%d ",save[a][i]); if(save[a][i]>=1 && save[a][i]<=13) printf("%s of Clubs\n",str[save[a][i]%13]); else if(save[a][i]>=14 && save[a][i]<=26) printf("%s of Diamonds\n",str[save[a][i]%13]); else if(save[a][i]>=27 && save[a][i]<=39) printf("%s of Hearts\n",str[save[a][i]%13]); else if(save[a][i]>=40 && save[a][i]<=52) printf("%s of Spades\n",str[save[a][i]%13]); } printf("\n"); } return 0; }