码迷,mamicode.com
首页 > Windows程序 > 详细

C#代码入门

时间:2018-04-11 18:06:33      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:else   names   class   入门   ==   break   back   console   value   

这是一个C#程序

  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Text;
  6.  
  7. namespace FindTheNumber
  8.  
  9. {
  10.   class Program
  11.   {
  12.     static void Main(string[] args)
  13.     {
  14.       int [] rg =
  15.           {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
  16.            20,21,22,23,24,25,26,27,28,29,30,31};
  17.       for (Int64 i = 1; i < Int64.MaxValue; i++)
  18.       {
  19.         int hit = 0;
  20.         int hit1 = -1;
  21.         int hit2 = -1;
  22.         for (int j = 0; (j < rg.Length) && (hit <=2) ; j++)
  23.         {
  24.           if ((i % rg[j]) != 0)
  25.           {
  26.             hit++;
  27.             if (hit == 1)
  28.             {
  29.               hit1 = j;
  30.             }
  31.             else if (hit == 2)
  32.             {
  33.               hit2 = j;
  34.             }
  35.             else
  36.               break;
  37.           }
  38.  
  39.         }
  40.         if ((hit == 2)&& (hit1+1==hit2))
  41.         {
  42.           Console.WriteLine("found {0}", i);
  43.         }
  44.       }
  45.     }
  46.   }
  47. }

 

C#代码入门

标签:else   names   class   入门   ==   break   back   console   value   

原文地址:https://www.cnblogs.com/wangyawei/p/8797009.html

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