zoukankan      html  css  js  c++  java
  • 5.14 am 练习

    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _2016._5._14
    {
        class Program
        {
    
                //100以内与7有关的数
            public void a1()
            {
                for (int i = 1; i <= 100; i++)
                {
                    if (i % 10 == 7)
                    {
                        Console.Write(i);
                    }
                    else if (i / 10 == 7)
                    {
                        Console.Write(i);
                    }
                    else if (i % 7 == 0)
                    {
                        Console.Write(i);
                    }
                }
            }
    
            //   前20 关   
            //21-30      10
            //31-40     20
            //41-49     30
            //50        100
    
            public void a2()
            {
                Console.Write("关数:");
                int g = int.Parse(Console.ReadLine());
                int s = 0;
                if (g > 0 && g <= 50)
                {
                    for (int i = 1; i <= g; i++)
                    {
                        if (i <= 20)
                        {
                            s += i;
    
                        }
                        else if (i > 20 && i <= 30)
                        {
                            s += 10;
                        }
                        else if (i > 30 && i <= 40)
                        {
                            s += 20;
                        }
                        else if (i > 40 && i < 50)
                        {
                            s += 30;
                        }
                        else
                        {
                            s += 100;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("输入错误!!");
                }
                Console.WriteLine(s);
    
            }
    
    
            //99乘法
    
            public void a3()
            {
                for (int a = 1; a <= 9; a++)
                {
                    for (int b = 1; b <= a; b++)
                    {
                        Console.Write(b + "*" + a + "=" + a * b + "	");
                    }
                    Console.WriteLine("
    ");
                }
            }
    
            //100以内奇数和      i%2!=0
            public void a4()
            {
                int s = 0;
                for (int a = 1; a <= 100; a++)
                {
                    if (a % 2 != 0)
                    {
                        s += a;
                    }
    
                }
                Console.WriteLine("100以内奇数和" + s);
    
            }
    
            //1, 2, 5   
                    //=60    几种组合
                //1,2,5各多少个
    
                public void a5()
        {
                int zh = 0;
                for (int a = 0; a <= 60; a++)      //1分
                {
                    for (int b = 0; b <= 30; b++)      // 2分
                    {
                        for (int c = 0; c <= 12; c++)    //5分
                        {
                          if (a+2*b+5*c==60)
                            {
                                zh++;
                                Console.WriteLine("" + zh + "种组合:1分" + a + "个,2分" + b + "个,5分"+c+"");               
                            }
                        }
                    }
                }
                Console.WriteLine("" + zh + "种组合");
    }
    
    
            static void Main(string[] args)
            {
              Program a=new Program ();
              //100以内与7有关的数
              
              //for (int i = 1; i <= 100; i++)
              //{
              //    if (i % 10 == 7)
              //    {
              //        Console.Write(i);
              //    }
              //    else if (i / 10 == 7)
              //    {
              //        Console.Write(i);
              //    }
              //    else if (i % 7 == 0)
              //    {
              //        Console.Write(i);
              //    }
              //}
    
              //a.a1();
    
               //   前20 关   
               //21-30      10
                //31-40     20
                //41-49     30
                //50        100
    
    
                //Console.Write("关数:");         
                //int g=int.Parse( Console.ReadLine());
                //int s = 0;
                //if (g > 0 && g <= 50)
                //{
                //    for (int i = 1; i <= g; i++)
                //    {
                //        if (i <= 20)
                //        {
                //            s += i;
    
                //        }
                //        else if (i > 20 && i <= 30)
                //        {
                //            s += 10;
                //        }
                //        else if (i > 30 && i <= 40)
                //        {
                //            s += 20;
                //        }
                //        else if (i > 40 && i < 50)
                //        {
                //            s += 30;
                //        }
                //        else
                //        {
                //            s += 100;
                //        }
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("输入错误!!");
                //}
                //Console.WriteLine(s);
    
              //a.a2();
              
    
    
    
                //99乘法
    
    
                //for (int a = 1; a <= 9; a++)
                //{
                //    for (int b = 1; b <= a; b++)
                //    { 
                //            Console.Write(b + "*" + a + "=" + a * b + "	");
                //    }
                //    Console.WriteLine("
    ");
                //}
    
             // a.a3();
    
    
                //100以内奇数和      i%2!=0
                //int s=0;
                //for (int a = 1; a <= 100; a++)
                //{
                //    if (a % 2 != 0)
                //    {
                //        s += a;
                //    }
                    
                //}
                //Console.WriteLine("100以内奇数和"+s); 
    
              //a.a4();
    
    
    
                    //1, 2, 5   
                    //=60    几种组合
                //1,2,5各多少个
    
                //int zh = 0;
                //for (int a = 0; a <= 60; a++)      //1分
                //{
                //    for (int b = 0; b <= 30; b++)      // 2分
                //    {
                //        for (int c = 0; c <= 12; c++)    //5分
                //        {
                //          if (a+2*b+5*c==60)
                //            {
                //                zh++;
                //                Console.WriteLine("第" + zh + "种组合:1分" + a + "个,2分" + b + "个,5分"+c+"个");               
                //            }
                //        }
                //    }
                //}
                //Console.WriteLine("有" + zh + "种组合");
    
    
             // a.a5();
    
    
                    Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    爬虫-scrapy初试
    python-爬虫day1
    django 内存地址列表-->转换为-->字典
    django 基于 form 验证 确认密码的注册
    django 请求过程,生命周期
    django7 models 高级应用
    django6-项目练习
    Mysql之起始
    python之IO模型
    python模块之Gevent(协程)
  • 原文地址:https://www.cnblogs.com/a454966933/p/5492315.html
Copyright © 2011-2022 走看看