⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 这是.net2005学习不可缺少的教程
💻 CS
字号:
using System;

namespace ZS
{
	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: 在此处添加代码以启动应用程序
			//

			//方法一
			int count1=0;
			for(int i=2;i<=1000;i++)
			{
				bool state=false;
				for(int j=2;j<i;j++)
				{
					count1++;
					if(i%j==0)
					{
						state=true;
					}
				}
				if(!state)
				{
					Console.Write("{0}\t",i);
				}
			}
			Console.WriteLine();
			Console.WriteLine("==========Counts is {0}============",count1);


			//方法二
			int count2=0;
			for(int i=2;i<=1000;i++)
			{
				bool state=false;
				for(int j=2;j<=(int)(Math.Sqrt(i));j++)		//*****************
				{
					count2++;
					if(i%j==0)
					{
						state=true;
					}
				}
				if(!state)
				{
					Console.Write("{0}\t",i);
				}
			}
			Console.WriteLine();
			Console.WriteLine("==========Counts is {0}============",count2);


			//方法三
			int count3=0;
			for(int i=2;i<=1000;i++)
			{
				bool state=false;
				for(int j=2;j<=(int)(Math.Sqrt(i));j++)
				{
					count3++;
					if(i%j==0)
					{
						state=true;
						break;					//*****************************
					}
				}
				if(!state)
				{
					Console.Write("{0}\t",i);
				}
			}
			Console.WriteLine();
			Console.WriteLine("==========Counts is {0}============",count3);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -