static void Main(string[] args) { int z = 987; int gewei = z % 10; int baiwei=z/100; int shiwei=(z-baiwei*100)/10; Console.WriteLine("{0} {1} {2}",baiwei,shiwei,gewei); }
bai=z/100; shi=z%100/10; ge=z%10
int j=z%1000;//去掉百位前面的 int b=j/100;//取百位如果是字符串,确定是整数形式,那么: string x=z.Substring(z.Length-3,1);
try... static void Main(string[] args) { int z = 987; int gewei = z % 10; int baiwei=z/100; int shiwei=(z-baiwei*100)/10; Console.WriteLine("{0} {1} {2}",baiwei,shiwei,gewei); string zz = "987"; Console.WriteLine("{0} {1} {2}",zz[zz.Length-3],zz[zz.Length-2],zz[zz.Length-1]); }
int bai=z/100;
int shi=(z-bai*100)/10;
int ge=z%10;这样写最容易看懂了
string z=987;
string bai=z.substring(0,1);
string shi=z.substring(1,1);
string ge=z.substring(2,1)
{
int z = 987;
int gewei = z % 10;
int baiwei=z/100;
int shiwei=(z-baiwei*100)/10;
Console.WriteLine("{0} {1} {2}",baiwei,shiwei,gewei);
}
shi=z%100/10;
ge=z%10
int b=j/100;//取百位如果是字符串,确定是整数形式,那么:
string x=z.Substring(z.Length-3,1);
static void Main(string[] args) {
int z = 987;
int gewei = z % 10;
int baiwei=z/100;
int shiwei=(z-baiwei*100)/10;
Console.WriteLine("{0} {1} {2}",baiwei,shiwei,gewei);
string zz = "987";
Console.WriteLine("{0} {1} {2}",zz[zz.Length-3],zz[zz.Length-2],zz[zz.Length-1]);
}