码迷,mamicode.com
首页 > 其他好文 > 详细

2015.3.3(下)

时间:2015-03-03 18:26:39      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

练习了for循环、while等等!

一、打印菱形:

  Console.Write("请输入一个数");             int n = Convert.ToInt32(Console.ReadLine());             for (int i = 1; i <=n; i++)             {                 for (int b = 1; b <=n-i; b++)                 {                                            Console.Write("..");                                                                                   }                 for (int i2 = 1; i2 <= 2*i-1; i2++)                 {                     Console.Write("☆");                 }                 Console.Write("\n");

            }             for (int a = 1; a <n; a++)             {                 for (int c = 1; c <=a; c++)                 {                     Console.Write("..");                 }                 for (int d = 1; d <=2*(n-a)-1; d++)             {                 Console.Write("☆");

            }Console.Write("\n");                            }              Console.ReadLine();

二、100节楼梯,前50节每节分数等于阶梯数,当第30节时直接跳到第50节得100分,51节开始每节10分。

//Console.WriteLine("请输入一个值");             //int a = Convert.ToInt32(Console.ReadLine());             //int n = 0;             //int m = 0;             //while (n<100)             //{             //    n++;             //    if (n<=30)             //    {             //        m = m + n;             //        Console.WriteLine("到"+n+"层数的分数"+m);             //    }             //    if (n>30&&n<=50)             //    {             //        if (n==50)             //        {             //            m += 100;             //            Console.WriteLine("到50层时分数"+m);             //        }             //        continue;             //        if (n>50)             //        {             //            m = m + 10;             //        }             //    }             //} Console.WriteLine(m);             //Console.ReadLine();

            //int a = 0; int sum = 0;             //while (a<=100)             //{             //    if (a%2==0)             //    {             //        sum += a;             //    }             //    if (a==90)             //    {             //        break;             //    }             //    a++;             //}             //Console.WriteLine(sum);

三:羽毛球拍15元,球3元,水2元。200元每种至少一个,有多少可能?

  //int m = 0;             //for (int x = 1; x*15<=200 ; x++)             //{             //    for (int y = 1; y*3 <=200; y++)             //    {             //        for (int z = 1; z*2 <=200; z++)             //        {             //            if (x*15+y*3+z*2==200&&x+z+y==43)             //            {             //                Console.WriteLine(x+"拍子数"+y+"球数"+z+"水数");             //                m++;             //            }             //        }             //    }             //}             //Console.WriteLine(m);             //Console.ReadLine();

            //int n = 1;             //while (n <= 6)             //{             //    Console.WriteLine("打印结果{0}{1}", n, 2 * n);             //}             //int m = 1;             //while (m<50)             //{             //    Console.WriteLine("打印结果为"+m);             //    m++;             //    if (m==6)             //    {             //        break;             //    }             //}             //Console.ReadLine();             //Console.WriteLine("请输入一个值");             //int a = Convert.ToInt32(Console.ReadLine());             //int n = 0;             //int m = 0;             //while (n<100)             //{             //    n++;             //    if (n<=30)             //    {             //        m = m + n;             //        Console.WriteLine("到"+n+"层数的分数"+m);             //    }             //    if (n>30&&n<=50)             //    {             //        if (n==50)             //        {             //            m += 100;             //            Console.WriteLine("到50层时分数"+m);             //        }             //        continue;             //        if (n>50)             //        {             //            m = m + 10;             //        }             //    }             //} Console.WriteLine(m);             //Console.ReadLine();

            //int a = 0; int sum = 0;             //while (a<=100)             //{             //    if (a%2==0)             //    {             //        sum += a;             //    }             //    if (a==90)             //    {             //        break;             //    }             //    a++;             //}             //Console.WriteLine(sum);

            //Console.WriteLine("输入一个数");             //int a = Convert.ToInt32(Console.ReadLine());             //Console.WriteLine("输入一个数");             //int b = Convert.ToInt32(Console.ReadLine());             //Console.WriteLine("输入一个停止数");             //int c = Convert.ToInt32(Console.ReadLine());             //int sum = 0;             //while (a<b)             //{             //    if (a%2==1)             //    {             //        sum += a;             //        if (a==c)             //        {             //            break;             //        }             //    } a++;             //}            //Console.WriteLine(sum);

           //Console.ReadLine();

 

2015.3.3(下)

标签:

原文地址:http://www.cnblogs.com/m123/p/4311514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!