using System;class Program { static void Main() { for ( int i = 1; i <= 256; i++ ) { if (i <= 26) Console.WriteLine((char)('A' + i - 1)); else Console.WriteLine("{0}{1}", (char)('A' + (i - 1) / 26 - 1), (char)('A' + (i - 1) % 26)); } } }
using System;class Program { static void Main() { for ( int i = 1; i <= 256; i++ ) { char a = (char)('A' + (i - 1) / 26 - 1); char b = (char)('A' + (i - 1) % 26); Console.WriteLine("{0}{1}", a < 'A' ? "" : a.ToString(), b); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace CSDNPRM3 { class Program { static int a1 = 65,a2=65; static string str1; static void Main(string[] args) { str1 = ""; for (int i = 1,p=1; i < 256; i++,p++) { if ((p % 26) == 0) { a2++; a1 = 65; } if (i < 27) { str1 = Convert.ToString((char)a1); } else { str1 = Convert.ToString((char)a2) + Convert.ToString((char)a1); } a1++; Console.Write("{0}\t", str1); } Console.ReadLine(); } } }
for (int i = 1; i <= 256; i++) { Console.Write(ItoA(i) + " "); } private string ItoA(int intVal) { int f1; int f2; f1 = intVal % 26; f2 = intVal / 26; if (f1 == 0) { f1 = 26; f2 = f2 - 1; } if (f2 == 0) { return Convert.ToChar(64 + f1).ToString();
判断 (i+1)/26 :
0的话什么也不输出
1则输出A
2 B
……第二位:
判断 (i+1)%26:
0则输出A
1则输出B
……
{
static void Main()
{
for ( int i = 1; i <= 256; i++ )
{
if (i <= 26)
Console.WriteLine((char)('A' + i - 1));
else
Console.WriteLine("{0}{1}", (char)('A' + (i - 1) / 26 - 1), (char)('A' + (i - 1) % 26));
}
}
}
{
static void Main()
{
for ( int i = 1; i <= 256; i++ )
{
char a = (char)('A' + (i - 1) / 26 - 1);
char b = (char)('A' + (i - 1) % 26);
Console.WriteLine("{0}{1}", a < 'A' ? "" : a.ToString(), b);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace CSDNPRM3
{
class Program
{
static int a1 = 65,a2=65;
static string str1;
static void Main(string[] args)
{
str1 = "";
for (int i = 1,p=1; i < 256; i++,p++)
{
if ((p % 26) == 0)
{
a2++;
a1 = 65;
}
if (i < 27)
{
str1 = Convert.ToString((char)a1);
}
else
{
str1 = Convert.ToString((char)a2) + Convert.ToString((char)a1);
}
a1++;
Console.Write("{0}\t", str1);
}
Console.ReadLine();
}
}
}
{
Console.Write(ItoA(i) + " ");
} private string ItoA(int intVal)
{
int f1;
int f2;
f1 = intVal % 26;
f2 = intVal / 26;
if (f1 == 0)
{
f1 = 26;
f2 = f2 - 1;
}
if (f2 == 0)
{
return Convert.ToChar(64 + f1).ToString();
} else {
return Convert.ToChar(64 + f2).ToString() + Convert.ToChar(64 + f1).ToString();
} }