zoukankan      html  css  js  c++  java
  • 建立一个个人档案字符串,然后输出

    技术:熟练String 类的Format()方法

    代码:

     class Program
        {
            static void Main(string[] args)
            {
                string name;
                int sex;
                string age;
                int height;
                string xuexing;
                string star;
                string favfood;
                Console.WriteLine("请输入你的姓名:");
                name=Console.ReadLine();
                Console.WriteLine("请输入你的姓别(1代表男,2代表女):");
                sex =int.Parse( Console.ReadLine());
                if (sex ==1)
                {
                    Console.WriteLine("");
                }
                else if (sex == 2)
                {
                    Console.WriteLine("");
                }
                else
                {
                    Console.WriteLine("请重新输入:");
                    sex = int.Parse(Console.ReadLine());
                }
                Console.WriteLine("请输入你的出生年月:");
                age=Console.ReadLine();
                Console.WriteLine("请输入你的身高(cm):");
                height = int.Parse(Console.ReadLine());
                Console.WriteLine("请输入你的血型:");
                xuexing = Console.ReadLine();
                Console.WriteLine("请输入你的星座:");
                star = Console.ReadLine();
                Console.WriteLine("请输入你最爱的食物:");
                favfood = Console.ReadLine();
                string record = string.Format("这是你的个人档案:\n姓名:{0}\n性别:{1}\n出生年月:{2}\n身高:{3}\n血型:{4}\n星座{5}\n最喜欢的食物{6}\n",
                    name,sex,age,height,xuexing,star,favfood);
                Console.WriteLine(record);
                Console.ReadLine();
            }
        }
  • 相关阅读:
    dotnet Framework 源代码 类库的意思
    dotnet Framework 源代码 类库的意思
    dotnet Framework 源代码 · Ink
    dotnet Framework 源代码 · Ink
    dotnet core 用值初始化整个数组
    dotnet core 用值初始化整个数组
    dotnet core 隐藏控制台
    dotnet core 隐藏控制台
    PHP mt_rand() 函数
    PHP mt_getrandmax() 函数
  • 原文地址:https://www.cnblogs.com/lqsilly/p/2917564.html
Copyright © 2011-2022 走看看