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

📄 qs.java

📁 这里面有JAVA和C的骑士问题的一些求解方法 大家可以做为参考 有什么问题可以在这里留言
💻 JAVA
字号:
import java.awt.*;
import java.applet.*;
public class Qs extends Applet
{   
    public void paint(Graphics g)
    {
    	 
         int y=10;
    
       for(int i=1;i<9;i++)
         { int x=10;
     
          for(int j=1;j<9;j++)
            { if(  (((i%2)==0)&&((j%2)==0))||(((i%2)!=0)&&((j%2)!=0) ) )
                { g.setColor(Color.red);
			     // g.drawRect(x,y,50,50);
		       	  g.fillRect(x,y,70,70);
		       	}
		      else
		      {g.setColor(Color.blue);
			     // g.drawRect(x,y,50,50);
		       	  g.fillRect(x,y,70,70);
		      }
			      x+=70;	
         	   
            }	
         	      y+=70;
        }
        
        
        
       int h[]={0,140,280,420,560,490,280,420,560,490,560,490,560,420,280,140,0,70,0,70,210,350,490,560,490,560,420,280,140};
    	 
    	 int z[]={0,70,0,70,0,140,560,490,560,420,280,140,0,70,0,70,140,280,420,560,490,560,490,350,210,70,0,70,0};
        
        for(int k=0;k<30;k++)
        
        {     int i=h[k];
              int j=z[k];
              g.setColor(Color.yellow);
              g.fillOval(i,j,20,20);
              try {Thread.sleep(1000);}
              catch(Exception e){return;}
          }   
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        }
      // public void paint2(Graphics g)
        //{  }
 }

        
        
        
        
        
        
        
        
        
        
        
        
        
        /*{if((k%2)!=0)
        { int i=140;
          int j=70;
     // {for(int j=0;j<580;j=j+70)
         g.setColor(Color.yellow);
          g.fillOval(i,j,20,20);
          i=i+280;
          try {Thread.sleep(1000);}
          catch(Exception e){return;}
         
         }
         else
         {int i=280;int j=0;
          g.setColor(Color.yellow);
           g.fillOval(i,j,20,20);
           i=i+280;
           try {Thread.sleep(1000);}
           catch(Exception e){return;}
          	
         }
 }*/
 
      	

⌨️ 快捷键说明

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