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();
            }
        }
  • 相关阅读:
    epoll源码实现分析[整理]
    linux几种时间函数总结
    linux几种定时函数的使用
    linux下redis数据库的简单使用
    网络编程之非阻塞connect编写
    网络编程之select
    数码相框(LCD、I2C)
    centos tftp和samba的安装与配置
    libevent库简单使用
    c语言随机数
  • 原文地址:https://www.cnblogs.com/lqsilly/p/2917564.html
Copyright © 2011-2022 走看看