zoukankan      html  css  js  c++  java
  • 函数及习题

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace 函数及习题讲解
    {
    class Program
    {
    访问修饰符 函数名(参数1,参数2)
    {
    函数体
    return 返回值
    }
    <summary>
    无参数,无返回值
    </summary>
    public static void abc()
    {
    Console.WriteLine("无参数,无返回值");
    }

    <summary>
    无参数,有返回值
    </summary>
    <param name="args"></param>
    public static int abc2()
    {
    return 1;
    }

    <summary>
    有参数,无返回值
    </summary>
    <param name="args"></param>
    public static void abc3(int a, int b)
    {
    Console.WriteLine(a + b);
    }
    <summary>
    有参数,有返回值
    </summary>
    <param name="args"></param>
    public static int abc4(int x, int y)
    {
    return x * y;
    }
    struct stu
    {
    public int id;
    public string name;
    public DateTime birthday;
    public double mark;
    public int age;
    }
    static void Main(string[] args)
    {
    abc();

    Console.WriteLine(abc2());

    abc3(1, 2);

    Console.WriteLine(abc4(2, 3));
    Console.WriteLine("请输入学生数");
    int count = int.Parse(Console.ReadLine());
    Console.WriteLine("请输入学生信息: ");

    List<stu> st_list = new List<stu>();

    for(int i = 1; i <= count; i++)
    {
    stu st;
    Console.WriteLine("请输入第"+ i +"个学生学号");
    st.id = int.Parse(Console.ReadLine());
    Console.WriteLine("请输入第" + i + "个学生姓名");
    st.name = Console.ReadLine();
    Console.WriteLine("请输入第" + i + "个学生生日");
    st.birthday = Convert.ToDateTime(Console.ReadLine());
    Console.WriteLine("请输入第" + i + "个学生分数");
    st.mark = Convert.ToDouble(Console.ReadLine());
    //Console.WriteLine("请输入第" + i + "个学生年龄");
    st.age = DateTime.Now.Year - st.birthday.Year;

    st_list.Add(st);
    }


    foreach(var x in st_list)
    {
    Console.WriteLine(x.id+ " " + x.name + " " + x.birthday + " " + x.mark +" " + x.age + " ");
    }
    ArrayList alt = new ArrayList();

    for (int i = 1; i <= 100; i++)
    {
    alt.Add(i);
    }

    for (int i = 49, j = 90; i <= 58 && j <= 200; i++, j++)
    {

    alt.Insert(i, alt[j]);
    j++;

    }

    foreach (int x in alt)
    {
    Console.WriteLine(x);
    }

    Console.ReadLine();
    }
    }
    }

  • 相关阅读:
    Delphi WebService连接数据库
    编写一个单独的Web Service for Delphi7(步骤)
    Delphi stdCall意义
    Delphi WEB APP DEBUGGER是如何使用的
    用delphi的THTTPRIO控件调用了c#写的webservice。
    Delphi 编写的Web Service
    Delphi WebService 中 Web App Debugger 的建议
    flex布局浅谈和实例
    IOS开关效果
    文字渐变和边框渐变
  • 原文地址:https://www.cnblogs.com/liuyubin0629/p/7002265.html
Copyright © 2011-2022 走看看