using System;
using System.Text;
public class SimpleColumnarTransposition
{
public static int rownumber(ref string Array,ref int Line)//判断数组的行数
{
int leavenumber=Array.Length%Line;
int row1=(int)(Array.Length/Line);
if (leavenumber==0)
{
return (row1-1);
}
else
{
return (row1);
}
}
public static char[][] getchar(ref int ROW,ref string mingwen,ref int Line)//返回类型要有
{
int count=0;//记是mingwen的第几个字符
char[][] ch=new char [ROW][];
for (int row2=0;row2<ROW;row2++)
{
for (int i=0,number=count;i<Line;i++,number++,count++)
{
while (count<mingwen.Length)
{
ch[row2][i]=mingwen[number];
}
}
}
return ch;
}
public static void Main()
{
int row,line;//row是行数,line是列数
string arg;
Console.WriteLine("输入你想输入的明文:");
arg=Console.ReadLine();
string args=arg.Replace(" ","");
Console.WriteLine("输入一个数字定义是几列的数组:");
line=Convert.ToInt32(Console.ReadLine());
row=rownumber(ref args,ref line);
char[][] cha=getchar(ref row,ref args,ref line);
Console.WriteLine("Press the key number:");
string s=Console.ReadLine();
foreach(char number1 in s)
{
int number2=(int)number1;
for (int x=0;x<row;x++)
{
Console.WriteLine(cha[x][number2]);
}
}
}
}