• POJ1026


    10
    4 5 3 7 2 8 1 6 10 9
    1 Hello Bob
    1995 CERC
    0(n)
    0(k)
    n
    1-n(不重复,无序排列)
    k(执行次数)  字符串(注意字符串开头可以为空,这里不能用scanf()来读入字符串)
     
    #include<stdio.h>
    #include<string.h>
    int cipher(int k_key[200],int i,int k)	//肯能会产生循环,为了节省时间,寻找最小周期;并且找出第i个字符会落在数组key中的某位
    {
    	int j,t=i+1;
    	i++;
    	for(j=1;j<=k;j++)
    	{
    		i=k_key[i-1];
    		if(i==t)
    		{
    			for(i=t,t=0;t<(k%j);t++)	//利用最小周期
    				i=k_key[i-1];
    			return i;
    		}
    	}
    	return i;
    }
    int main()
    {
    	int n,k,key[200],len,i;
    	char temp[201],str[201];
    	while(scanf("%d",&n)!=EOF&&n!=0)
    	{
    		for(i=0;i<n;i++)
    		scanf("%d",&key[i]);
    		while(scanf("%d",&k)!=EOF&&k!=0)
    		{
    			getchar();
    			gets(temp);
    			len=strlen(temp);
    			if(len<n)
    				for(i=len;i<n;i++)
    					temp[i]=' ';
    			for(i=0;i<n;i++)
    				str[cipher(key,i,k)-1]=temp[i];		//从以上函数找出的i,确定字符数组str[i(自定义函数中的i)-1]为原先输入函数中对应的temp[i(主函数中的i)]
    			for(i=n-1;;i--)
    				if(str[i]!=' ')
    				{
    					str[i+1]='\0';
    					break;
    				}
    			printf("%s\n",str);
    		}
    		printf("\n");
    	}
    	return 0;
    }
    
  • 相关阅读:
    由高度场求法线
    unity中的透视投影矩阵
    bindpose定义
    blinn-phong高光反向穿透问题
    fft ocean注解
    理顺FFT
    unity, 在image effect shader中用_CameraDepthTexture重建世界坐标
    unity, ComputeScreenPos 作用
    Lambert漫反射的BRDF
    VC++ MFC获取对话框上控件的位置
  • 原文地址:https://www.cnblogs.com/submarinex/p/1941313.html
Copyright © 2020-2023  润新知