123-练习3和4

3,编写一个控制台应用程序,要求用户输入4个int值,并显示他们的乘积。

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);

4,从键盘输入一个三位的正整数,把百分位十分位个分位数字的相反顺序输出。

            string str = Console.ReadLine();
            int num = Convert.ToInt32(str);
            int ge = num%10;// 一个数字跟10求余得到是这个数字的个分位
            int shi = (num/10)%10;//一个数字跟10相除的话,相当于去掉这个数字的个分位( xyz/10 = xy )
            int bai = num/100;
            Console.WriteLine(ge+""+shi+""+bai);
            Console.ReadKey();

  

posted @ 2018-11-15 20:18  阿晖2222  阅读(345)  评论(0编辑  收藏  举报