Console.WriteLine("请输入一个三位数:");
int num = int.Parse(Console.ReadLine());
int num1 = num / 100;
int num2 = num / 10 % 10;
int num3 = num % 10;
if (num1 * num1 * num1 + num2 * num2 * num2 + num3 * num3 * num3 == num)
{
Console.WriteLine("{0}是一个水仙花数", num);
}
else
{
Console.WriteLine("{0}不是一个水仙花数", num);
}
Console.WriteLine("请输入一个数:");
int x = int.Parse(Console.ReadLine());
if (x >= 0)
{
Console.WriteLine("这个数的绝对值是" + x);
}
else
{
x = -x;
Console.WriteLine("这个数的绝对值是" + x);
}
Console.WriteLine("请输入一个数字:");
int a = int.Parse(Console.ReadLine());
if (a > 0 && a < 10)
{
Console.WriteLine(a + "是个一位数");
}
else if (a >= 10 && a < 100)
{
Console.WriteLine(a + "是个两位数");
}
else if (a >= 100 && a < 1000)
{
Console.WriteLine(a + "是个三位数");
}
else if (a >= 1000 && a < 10000)
{
Console.WriteLine(a + "是个四位数");
}
else
{
Console.WriteLine("请输入正确的数字!");
}
Console.WriteLine("请输入两个数字和运算符:");
int x = int.Parse(Console.ReadLine());
int y = int.Parse(Console.ReadLine());
char z = char.Parse(Console.ReadLine());
switch (z)
{
case '+':
Console.WriteLine("{0}+{1}={2}", x, y, x + y);
break;
case '-':
Console.WriteLine("{0}-{1}={2}", x, y, x - y);
break;
case '*':
Console.WriteLine("{0}*{1}={2}", x, y, x * y);
break;
case '/':
Console.WriteLine("{0}/{1}={2}", x, y, x / y);
break;
Console.WriteLine("请输入学生成绩:");
int grade = int.Parse(Console.ReadLine());
if (grade >= 90)
{
Console.WriteLine("成绩等级为:A");
}
else if (grade >= 80 && grade < 90)
{
Console.WriteLine("成绩等级为:B");
}
else if (grade >= 70 && grade < 80)
{
Console.WriteLine("成绩等级为:B");
}
else if (grade >= 60 && grade < 70)
{
Console.WriteLine("成绩等级为:B");
}
else if (grade >= 0 && grade < 60)
{
Console.WriteLine("成绩等级为:E");
}
else
{
Console.WriteLine("请输入正确的成绩!");
}
Console.WriteLine("请输入员工的年工资:");
int sum = int.Parse(Console.ReadLine());
Console.WriteLine("请输入员工类型:");
char type = char.Parse(Console.ReadLine());
if (type == 'A')
{
Console.WriteLine("该员工的年终奖是" + sum * 0.3);
}
else if (type == 'B')
{
Console.WriteLine("该员工的年终奖是" + sum * 0.25);
}
else if (type == 'C')
{
Console.WriteLine("该员工的年终奖是" + sum * 0.2);
}
else if (type == 'D')
{
Console.WriteLine("该员工的年终奖是" + sum * 0.15);
}
else
{
Console.WriteLine("请输入正确的员工类型!");
}
Console.WriteLine("请输入年份:");
int year = int.Parse(Console.ReadLine());
Console.WriteLine("请输入月份:");
int month = int.Parse(Console.ReadLine());
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
Console.WriteLine("{0}月有31天", month);
break;
case 4:
case 6:
case 9:
case 11:
Console.WriteLine("{0}月有30天", month);
break;
case 2:
if ((year % 4 == 0 && month % 100 != 0) || (year % 400 == 0))
{
Console.WriteLine("{0}月有29天", month);
}
else
{
Console.WriteLine("{0}月有28天", month);
}
break;
}
Console.WriteLine("请输入学生成绩(0-100):");
int a = int.Parse(Console.ReadLine());
if (a >= 90)
{
Console.WriteLine("成绩为优");
}
else if (a >= 80 && a < 90)
{
Console.WriteLine("成绩为良");
}
else if (a >= 70 && a < 80)
{
Console.WriteLine("成绩为中");
}
else if (a >= 60 && a < 70)
{
Console.WriteLine("成绩为及格");
}
else
{
Console.WriteLine("成绩为不及格");
}
Console.WriteLine("请输入十个数:");
int i = 1;
int sum = 0;
do
{
int num = int.Parse(Console.ReadLine());
sum += num;
i++;
} while (i <= 10);
Console.WriteLine("这十个数的和为:" + sum);
Console.WriteLine("请输入用户名:");
string name = Console.ReadLine();
Console.WriteLine("请输入密码:");
string code = Console.ReadLine();
int i = 1;
if (code != "123456")
{
while (code != "123456")
{
Console.WriteLine("密码错误,请重试!");
code = Console.ReadLine();
i++;
if (code == "123456")
{
Console.WriteLine("登陆成功!");
break;
}
else if (i >= 3)
{
Console.WriteLine("今日错误次数已达上限!");
break;
}
}
}
else
{
Console.WriteLine("登陆成功!");
}
int x = 1, y = 1, z = 0;
for (int i = 1; x + y < 100; i++)
{
z = x + y;
x = y;
y = z;
}
Console.WriteLine(z);
int i = 2;
while (true)
{
if (i % 2 == 1 && i % 3 == 1 && i % 4 == 1)
{
break;
}
i++;
}
Console.WriteLine("这个篮子里有" + i + "个鸡蛋");
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write("{0}*{1}={2}\t", j, i, j * i);
}
Console.WriteLine();
}
Console.WriteLine("请输入十名同学的成绩:");
int[] a = new int[10];
int max = a[0];
int sum = 0;
for (int i = 0; i < a.Length; i++)
{
int x = int.Parse(Console.ReadLine());
a[i] = x;
if (a[i] >= max)
{
max = a[i];
}
sum += a[i];
}
int min = a[0];
for (int i = 0; i < a.Length; i++)
{
if (a[i] <= min)
{
min = a[i];
}
}
Console.WriteLine("最高分是:{0},最低分是:{1},平均分是:{2}", max, min, sum / 10);
Console.WriteLine("请输入十个数:");
int sum = 0, sum1 = 0;
for (int i = 1; i <= 10; i++)
{
int num = int.Parse(Console.ReadLine());
if (num >= 0)
{
sum += num;
}
else
{
sum1 += num;
}
}
Console.WriteLine("正数和:" + sum);
Console.WriteLine("负数和:" + sum1);
Console.WriteLine("请输入十个数:");
int[] a = new int[10];
for (int i = 0; i < a.Length; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("逆序的是:");
for (int k = 9; k >= 0; k--)
{
Console.WriteLine(a[k]);
}
int[] num = new int[] { 3, 6, 1, 5, 2, 10, 9, 8, 4, 7 };
int t;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 9; j++)
{
if (num[j] > num[i])
{
t = num[j];
num[j] = num[i];
num[i] = t;
}
}
}
Console.WriteLine("从小到大排列是:");
for (int k = 0; k < 10; k++)
{
Console.WriteLine(num[k]);
}
Console.WriteLine("请输入一个数:");
int n = int.Parse(Console.ReadLine());
while (true)
{
if (n >= 0)
{
for (int i = 1; i < n; i++)
{
Console.WriteLine(i);
}
}
else
{
break;
}
n = int.Parse(Console.ReadLine());
}
int sum = 0;
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 != 0)
{
sum += i;
}
}
Console.WriteLine(sum);
Console.WriteLine("请输入行数:");
int row = int.Parse(Console.ReadLine());
for (int i = 1; i <= row; i++)
{
for (int j = 1; j <= row - i; j++)
{
Console.Write(" ");
}
for (int k = 1; k <= 2 * i - 1; k++)
{
Console.Write("*");
}
Console.WriteLine();
}
欢迎点赞 收藏 留言
单纯分享日常中的小练习,技术有限,如果发现有错欢迎指导