zoukankan      html  css  js  c++  java
  • C#基础_占位符(四)

    语法:字符串中加大括号加上数字 “第{0}个数字”,i

      注意:大括号中数字是对应逗号后边第几个数据,从0开始计数

         逗号后不一定是数字,也可以是字符串

        逗号的数据,也不一定都要在占位符中都用到

        大括号中的数据可以重复

    单个占位符:

       Console.WriteLine("第{0}个数字",12); //第12个数字

      Console.WriteLine("第{0}个数字","ss");

      Console.WriteLine("第{0}个数字",12,13);

    多个占位符:

      int num = 1, num2 = 2, num3 = 4 ;
            Console.WriteLine("三个数字的和:{0},平均数:{1} ",num+num2+num3,(num+num2+num3)/3);

      大括号中的数据可以一样,0对应num,1对应num2
                Console.WriteLine("{0}--{1}---{1}",num,num2);

    练习:

     1 //1.练习:编程实现107653秒是几天几小时几分钟几秒?
     2 
     3             int seconds = 107653;
     4             int days = seconds / (24 * 3600); //一天有 60 * 60*24 秒,得到有多少天
     5             int mod = seconds % (24 * 3600); //得到出去计算天数所用的秒
     6             int hour = mod / 3600;//得到多少个小时
     7             mod = mod % 3600; //
     8             int min = mod / 60;
     9             int sec = mod % 60;
    10             Console.WriteLine("{0}秒里包含{1}第三天{2}小时{3}分{4}秒", seconds, days, hour, min, sec);
  • 相关阅读:
    VSCode配置Python开发环境
    图像特征——边缘
    关于相机内参中的焦距fx和fy
    摄影变换和仿射变换
    为什么要引入齐次坐标
    链表一
    从小问题看懂链表
    类与对象
    排序一
    数组
  • 原文地址:https://www.cnblogs.com/CeasarH/p/9163312.html
Copyright © 2011-2022 走看看