zoukankan      html  css  js  c++  java
  • 函数,在函数中赋值,然后输出

     public int SumZhiShu(int n)
            {
                int sum = 0;

                for (int i = 1; i <= n; i++)
                {
                    int count = 0;
                    for (int j = 1; j <= i; j++)
                    {
                        if (i % j == 0)
                        {
                            count++;
                        }
                    }
                    if (count == 2)
                    {
                        sum += i;
                    }
                }

                return sum;
            }

            //输入参数对于函数而言,相当于已经赋值了的变量,直接可用。
            //输出参数相当于定义了一个变量,需要在函数中为其赋值,然后调用函数的时候将所赋值带出函数。
            public void shuchu(int a, out int b)
            {
                b = a + 10;
            }

            static void Main(string[] args)
            {
                HanShu hs = new HanShu();//函数所在类的初始化
                int sum = hs.SumZhiShu(100);//通过类来调用函数
                Console.WriteLine(sum);

                int c = 11;
                int d;
                hs.shuchu(c,out d);

                Console.WriteLine(d);

                Console.ReadLine();

  • 相关阅读:
    百度mp3地址解密码
    VB 在EXE后附加信息
    截屏函数
    Base64和StrToByte
    The Android ION memory allocator, DMABUF is mentioned as well
    DDC EDID 介绍
    Memory management for graphic processors TTM的由来
    科普 写display driver的必看 How video card works [2D的四种主要操作]
    GEM vs TTM
    DMABUF 背景介绍文章 Sharing buffers between devices
  • 原文地址:https://www.cnblogs.com/liuyuwen900326/p/4184164.html
Copyright © 2011-2022 走看看