首页 > 其他 > 详细

123-练习3和4

时间:2018-11-15 20:34:54      阅读:190      评论:0      收藏:0      [点我收藏+]

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

  

123-练习3和4

原文:https://www.cnblogs.com/wuxiaohui1983/p/9965848.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!