siki学院的习题及答案
int hp;
float x;
float y;
float z;
float speed;
string str1 = Console.Readline();
int num1 = Convert.ToInt32(str1);
string str2 = Console.Readline();
int num2 = Convert.ToInt32(str2);
int temp = num1;
num1 = num2;
num2 = temp;
Console.Writeline(num1+”:“+num2);
Console.ReadKey();
string str1 = Console.Readline();
int num1 = Convert.ToInt32(str1);
string str2 = Console.Readline();
int num2 = Convert.ToInt32(str2);
string str3 = Console.Readline();
int num3 = Convert.ToInt32(str3);
string str4 = Console.Readline();
int num4 = Convert.ToInt32(str4);
int res = num1 * num2 * num3 * num4;
Console.writeline(res);
Console.ReadKey();
string numStr = "234";
int num =234;
int ge = num%10;
int shi =((num - ge)/10)%10;
int bai =num /100;
Console.Writeline(ge+”“+shi+””+bai);
Console.ReadKey();
Console.Writeline(“请输入上底”);
string str1 = Console.Readline();
double num1 = Convert.ToDouble(str1);
Console.Writeline(“请输入下底”);
string str2 = Console.Readline();
double num2 = Convert.ToDouble(str2);
Console.Writeline(“请输入高”);
string str3 = Console.Readline();
double num3 = Convert.ToDouble(str3);
double res = (num1 + num2) * num3 /2;
Console.Writeline(res);
Console.ReadKey();
Console.Writeline(“请输入圆的半径”);
string str = Console.Readline();
double n = Conver.ToDouble(str);
Console.Writeline(“圆的周长是” + (2 * n * 3.14));
Console.Writeline(“圆的面积是” + (n * n * 3.14));
Console.ReadKey();
int num1 = Convert.ToInt32(Console.Readline());
int num2 = Convert.ToInt32(Console.Readline());
int num3 = Convert.ToInt32(Console.Readline());
int num4 = Convert.ToInt32(Console.Readline());
int max,min;
If(num1 > num2)
{
max = num1;
}
else
{
max = num2;
}
If(num3 > max)
{
max = num3;
}
If(num4 > max)
{
max = num4;
}
If(num1 < num2)
{
min = num1;
}
else
{
min = num2;
}
If(num3 < min)
{
min = num3;
}
If(num4 < min)
{
min = num4;
}
Console.Writeline(“最大值是:” + max + “最小值是:” + min);
Console.ReadKey();
Console.Writeline(“Please enter first number”);
int num1 = Convert.ToInt32(Console.Readline());
Console.Writeline(“Please enter second number”);
int num2 = Convert.ToInt32(Console.Readline());
Console.Writeline(“请输入0-3之间的数字”);
int operation = Convert.ToInt32(Console.Readline());
int res = 0;
switch(operation)
{
case 0:
res = num1 + num2;
case1:
res = num1 - num2;
case2;
res = num1 * num2;
case3:
res = num1 / num2;
break;
}
Console.Writeline(“The result is:” + res);
Console.ReadKey();
int count = 0;
int sum = 0;
for(int i =1; i <= 1000; i++)
{
If(i % 7 == 0)
{
sum + = i;
count++;
Console.Writeline(i + “可以被7整除”);
If(count == 5)
{
Console.Writeline(“这5个的和是:” + sum)
sum = 0;
count =0;
}
}
}
Console.ReadKey();
4,编写一个控制台程序,分别输出1~100之间的平方、平方根。
for(int i =1; i <= 100; i++)
{
int pingfang = i * i;
double gen = Math.Sqrt(i);
Console.Writeline(“平方为:” + i + “平方根为:” + gen)
}
Console.ReadKey();
int sum = 0;
for(int i = 1; i <= 100; i++)
{
If((i % 3 == 0)&&(i % 5 != 0))
{
sum++;
Console.Writeline(i);
}
}
Console.Writeline(sum);
Console.ReadKey();
for(int i = 2; i < 1001; i++)
{
bool isZhishu = true;
for(int j = 2; j <= i - 1; j++)
{
If(i % j == 0)
{
isZhishu = false;
break;
}
}
If(isZhishu)
{
Console.Writeline(i);
}
}
Console.ReadKey();
for(int i = 1; i < 10; i++)
{
for(int j = 1; j < 10; j++)
{
Console.Write(i + “*” + “=” + (i*j) + “ “);
}
Console.Writeline();
}
Console.ReadKey();
int num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0;
Random random = new Random();//创建一个可以生成随机数的对象
for(int i = 0; i < 100; i++)
{
Int num = random.Next(1,7);//random.Next()包含最小不包含最大,筛子有六面所以得一到七
switch(num)
{
case 1;
num1++;
break;
case 2;
num2++;
break;
case 3;
num3++;
break;
case 4;
num4++;
break;
case 5;
num5++;
break;
case 6;
num6++;
break;
}
}
Console.Writeline(num1);
Console.Writeline(num2);
Console.Writeline(num3);
Console.Writeline(num4);
Console.Writeline(num5);
Console.Writeline(num6);
Console.ReadKey();
for(int i = 1; i < 6; i++)
{
Console.Writeline(i * i);
}
Console.ReadKey();
int index = 1;
while(index < 6)
{
Console.Writeline(index * index);
Index++;
}
Console.ReadKey();
Int index = 1;
do
{
Console.Writeline(index * index);
index++;
}while(index < 6);
Console.Readkey();
while(true)
{
string str = console.readline();
bool isAIUpperChar = true;
for(int i = 0; i < 5; i++)
{
if(str[i] >= ‘A’ && str[i] <= ‘Z’)
{
}
else
{
isAIUpperChar = false;
break;
}
}
if(isAIUpperChar == false)
{
console.writeline(“您输入的5个字母,不全是大写字母,请重新输入”);
}
else
{
break;
}
Console.Readkey();
while(true)
{
int num = convert.toint32(console.readline());
if(num > 0)
{
for (int i = 1; i <= num; i++)
{
Console.Write(i + “ “);
}
Console.Writeline();
}
else if(num < 0)
{
return;
}
}
for(int i = 1; i < 1001; i++)
{
string str = “1”;
int sum = 1;
for(int j = 2; j < i; j++)
{
if(i % j == 0)
{
str += “+” + j;
sum += j;
}
}
if(sum == i)
{
Console.Writeline(i + “是完数” + str);
}
}