zoukankan      html  css  js  c++  java
  • 函数的练习

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Collections;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            //找出100以内的于7 有关的数打印
            //从1找到100
            //找出和7有关的数
            //public void shu()
            //{
            //    for (int i = 1; i <= 100; i++)
            //    {
            //        if (i % 10 == 7)
            //        {
            //            Console.WriteLine(i + "个位数是7");
            //        }
            //        else if (i / 10 == 7)
            //        {
            //            Console.WriteLine(i + "十位数是7");
            //        }
            //        else if (i % 7 == 0)
            //        {
            //            Console.WriteLine(i + "被7整除");
            //        }
            //    }
            //}
            //一个游戏,前20关  每一关是自己的分数
            //21-30每一关是10分
            //31-40每一关是20分
            //41-49每一关是30分
            //50关是100分
            //输入当前管卡数。求你现在拥有的分数
            //public int youxi(int z)
            //{
            //    int sum = 0;
            //    if (z > 0 && z<= 50)
            //    {
            //        for (int i = 0; i <=z; i++)
            //        {
            //            if (i <= 20 && i > 0)
            //            {
            //                sum += i;
            //            }
            //            else if (i > 20 && i < 31)
            //            {
            //                sum += 10;
            //            }
            //            else if (i >= 31 && i < 41)
            //            {
            //                sum += 20;
            //            }
            //            else if (i >= 41 && i <= 49)
            //            {
            //                sum += 30;
            //            }
            //            else if (i == 50)
            //            {
            //                sum += 100;
            //            }
            //        }
                   
            //    }
            //    else
            //    {
            //        Console.WriteLine("您输入的关数有误!");
            //    }
            //    return sum;
    
            //}
            //99口诀表
            //一行一行打印
           // public void chengfa()
           //{
           //  for (int a = 1; a <= 9; a++)
           //     {
           //         for (int b = 1; b <= a; b++)
           //         {
           //             Console.Write(a + "*" + b + "=" + a * b + "	");
           //         }
           //         Console.WriteLine();
           //     }
           // }    
    
    
    
            //100以内的奇数和
            //public void he()
            //{
            //    int sum = 0;
            //    for (int i = 0; i < 100; i++)
            //    {
            //        if (i % 2 != 0)
            //        {
            //            sum += i;
            //        }
            //    }
            //    Console.WriteLine(sum); 
            //}
    
    
    
    
            //有1分 2分 5分
            //求6角的组合方式
            public int  zuhe()
            {
                int sum = 0;
                for (int x = 0; x <= 60; x++)
                {
                    for (int y = 0; y <= 30; y++)
                    {
                        for (int z = 0; z <= 12; z++)
                        {
                            if (x + 2 * y + 5 * z == 60)
                            {
                                Console.WriteLine("1分" + x + "个,2分" + y + "个,5分" + z + "");
                                sum++;
                            }
                        }
                    }
                }
                return sum;
            
            }
     
    
    
    
            static void Main(string[] args)
            {
                //找出100以内的于7 有关的数打印
                //从1找到100
                //找出和7有关的数
                //Program hs = new Program();
                //hs.shu();
                //Console.ReadLine();
    
    
    
    
                //一个游戏,前20关  每一关是自己的分数
                //21-30每一关是10分
                //31-40每一关是20分
                //41-49每一关是30分
                //50关是100分
                //输入当前管卡数。求你现在拥有的分数
                //Program hs = new Program();
                //Console.Write("请输入当前关数");
                //int a = int.Parse(Console .ReadLine ());
                //int sum=hs.youxi(a);
                //Console.WriteLine(sum);
                //Console.ReadLine();
                
    
    
    
                ////99口诀表
                ////一行一行打印
                //Program hs = new Program();
                //hs.chengfa ();
                //Console.ReadLine();
    
    
    
                //100以内的奇数和
                //Program hs = new Program();
                //hs.he();
                //Console.ReadLine();
    
    
    
                //有1分 2分 5分
                //求6角的组合方式
                Program hs = new Program();
                 int sum=hs.zuhe();
                Console.WriteLine(sum);
                Console.ReadLine();
    
    
            }
        }
    }
  • 相关阅读:
    hibernate_0100_HelloWorld
    MYSQL子查询的五种形式
    JSF是什么?它与Struts是什么关系?
    nop指令的作用
    htmlparser实现从网页上抓取数据(收集)
    The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the
    FCKeditor 在JSP上的完全安装
    Java遍历文件夹的2种方法
    充电电池和充电时间说明
    吃知了有什么好处
  • 原文地址:https://www.cnblogs.com/zhangdemin/p/5492093.html
Copyright © 2011-2022 走看看