2023-01-30
自我提升
0

✍编程题:
阅读以下程序:

c#
int x; x = Convert.ToInt32(Console.ReadLine()); if(x--<5) Console.WriteLine(x); else Console.WriteLine(x++);

程序运⾏后,如果从键盘上输⼊5,则输出结果是( )
A、3
B、4 ✔
C、5
D、6

✍编程题: 分析以下程序,下列说法正确的是( )

c#
int x=5,a=0,b=0; if(x=a+b) Console.WriteLine("****"); else Console.WriteLine("####");

A、由于语法错误,不能通过编译 ✔
B、通过编译,但是没有结果
C、输出****
D、输出####

✍编程题: 代码填空,求两个值中的较⼩值:( )

c#
int a,b; a = Convert.ToInt32(Console.WriteLine()); b = Convert.ToInt32(Console.WriteLine()); if( ? ) { Console.WriteLine(a); }else{ Console.WriteLine(b); }

A、a<b ✔
B、a>b
C、a<=b
D、a>=b

✍编程题: 执⾏下⾯程序后,运⾏结果是( )

c#
int x=21,y=1; if(x%3 == 0 && x%7 == 0){ x--; Console.WriteLine(x); }else{ x++; Console.WriteLine(x); }

A、 21
B、 22
C、 20 ✔
D、 0

✍编程题:排序
输⼊三个整数,把这三个数,从⼩到⼤排序后输出。
输⼊:8 3 5 输出 3 5 8

c#
int a = Convert.ToInt32(Console.ReadLine()); int b = Convert.ToInt32(Console.ReadLine()); int c = Convert.ToInt32(Console.ReadLine()); // a b b c a b if (a > b) { int temp = a; a = b; b = temp; } if (b > c) { int temp = b; b = c; c = temp; } if (a > b) { int temp = a; a = b; b = temp; } Console.WriteLine(a + " " + b + " " + c);

✍编程题
输⼊⼀个⼩数m和整数k(k为0,1)
如果k为0,则输出m保留整数部分。
如果k为1,则输出m,四舍五⼊保留1为⼩数。
样例
输⼊ 4.65 0 输出 4
输⼊ 4.65 1 输出4.7

c#
double m = Convert.ToDouble(Console.ReadLine()); int k = Convert.ToInt32(Console.ReadLine()); if (k == 0) { int temp = (int)m; Console.WriteLine(temp); } else { // 3.2543 + 0.05 =3.3043 *10 33.043 33 /10 3.3 double temp = ((int)((m + 0.05) * 10)) / 10.0; Console.WriteLine(temp); }

✍编程题: 如何判断⼀个单字符a是不是数字?( )
A、if(a>='0'&&a<='9') ✔
B、if(a>=0&&a<=9)
C、if(a>='0'||a<='9')
D、if(a>='0'&& a<='9') ✔

c#
char c = Convert.ToChar(Console.ReadLine()); // a-z if( c>='a' && c<='z') { Console.WriteLine("你输入的是一个小写字母"); } else { Console.WriteLine("你输入的不是一个小写字母"); }

✍编程题: 代码填空,输⼊⼀个字符,判断是不是数字,输出对应的数值: ( )

c#
char a; a=Convert.ToChar(Console.ReadLine()); if(a>='0'&&a<='9'){ ______; }

A、Console.WriteLine(a-'0'); ✔
B、Console.WriteLine(a-0);
C、Console.WriteLine(a+'0');
D、Console.WriteLine(a-'0'); ✔

//0-9 对于ascll 48-57

✍编程题:
如何判断⼀个数a是否同时能被3和5整除?( )
A、if(a%3==0||a%5==0)
B、if(a%3==0&&a%5==0) ✔
C、if(a/3==0&&a/5==0)
D、if(a/3==0||a/5==0)

✍编程题: 将三个数排序⾄少需要⽐较⼏次?( )
A、1
B、2
C、3 ✔
D、4

✍编程题:
下列代码输出的结果是: ( )
double a=3.14;
int b=(int)a;
Console.WriteLine(b);
A、 3.140
B、 3.14
C、 3.1
D、 3 ✔