内容发布更新时间 : 2025/7/7 7:23:31星期一 下面是文章的全部内容请认真阅读。
48、 下列程序的作用是求出所有的水仙花数。(所谓水仙花数是指这样的数:该数是三位数,其各位数字的立方和等于该数) using system; class Example1 {
static void Main(string[] args) {
int a, i, b, c, t;
for (i = 100; i <= 999; i++) { t = i;
a = t % 10; t = t / 10; b = t % 10; c = t / 10; if (i == a * a * a + b * b * b + c * c * c) Console.WriteLine(\ }
Console.ReadLine(); }}
49、public class TEApp{
public static void ThrowException(){
throw new Exception(); }
public static void Main(){
try{
Console.WriteLine(“try”); ThrowException(); }
catch(Exception e){
Console.WriteLine(“catch”); } finally{
Console.WriteLine(“finally”); } }
}上述C#代码运行结果是(try
catch finallyA)
50、分析如上的C#代码段,运行后将输出老师的名字叫小明 学生的名字叫小明 public class Teacher{
public Teacher (string name){
Console.WriteLine(“老师的名字叫”+ name);
}
}
public class Test:Teacher{
public Test(string name){
Console.WriteLine(“学生的名字叫”+ name); } }
static void Main(string[] args) { Test t=new Test(“小明”);} 51、class Test{
static void Main(){
try{
int a = 10; int b = 0; int c = a / b;
Console.WriteLine(c);
} catch{
Console.WriteLine(“出现错误”);
} finally{ Console.WriteLine(“运行结束”); }
}
}在C#中,上述代码的运行结果是出现错误
运行结束
52、下列程序是输出100以内所有能被7整除的数,请将程序补充完整。 using System; class Output { static void Main()
{for (int k=1;k<=100;___k++______ ) {if (k%7!=0) ; ____continue;________
<