java有趣的
就你出的题来说,没看懂,就java来说表示起始2,一直到N做循环
import java.util.Scanner;
public class FunNumber {
public static void main(String[] args) {
Scanner fin = new Scanner(System.in);
int N = fin.nextInt();
long i = (long)Math.pow(10, N-1);
long j = (long)Math.pow(10, N);
long count = 0;
for(;i<j;i++){
if(isFun(i,N)) {
count++;
System.out.println(i);
}
}
System.out.println("Count % 1000000007 = " + count%1000000007);
}
public static boolean isFun(long num,int N){
boolean[] num_exist = new boolean[4];
for(;N>0;N--){
int i = (int)(num%Math.pow(10,N)/Math.pow(10,N-1));
switch(i){
case 0:
num_exist[0] = true;
//0必须都在1前
if(num_exist[1]){
return false;
}
break;
case 1:
num_exist[1] = true;
break;
case 2:
num_exist[2] = true;
//2必须都在3前
if(num_exist[3]){
return false;
}
break;
case 3:
num_exist[3] = true;
break;
default:
//不只包含0123
return false;
}
}
//0123至少出现1次
if(num_exist[0]&&num_exist[1]&&num_exist[2]&&num_exist[3]){
return true;
}
return false;
}
}
B. 用java开发的大型游戏有哪些
Java开发的大型游戏有:俄罗斯方块、超级泡泡龙、贪吃蛇、钻石情迷、祖玛等。学习Java开发推荐千锋教育,教育培训业务分为大学生技能培训和职后技能培训;高校服务业务主要提供校企合作全解决方案与定制服务;企业服务业务主要为企业提供专业化综合服务,值得信赖。
用java开发的大型游戏有以下几个:
1、俄罗斯方块(Tetris)
经典的益智游戏,几乎是世界上最有影响力的益智游戏之一,游戏本身也很简单,只要不断消减掉落的方块就可以了。这个游戏被模仿了很多个版本,我这里的是EA出的疯狂俄罗斯方块(Tetris Mania)。
2、超级泡泡龙(Super Bubble Bobble)
Taito公司开发的游戏,主角是两只绿色和蓝色的小恐龙,通过吐出泡泡来消减屏幕上的彩球,游戏本身简单易学、妙趣横生,女孩子玩起来会上瘾的。
3、贪吃蛇(Retro Snaker)
诺基亚手机上的一个元老级游戏,这个游戏短小精悍,很具可玩性,特别适合在手机上玩。据称,已经有超过十亿人玩过这个游戏。
4、钻石情迷(Bejeweled)
一个很好玩的益智游戏,有点像“对对碰”,游戏规则很简单,移动相邻的两个钻石,使任一排产生有三个或以上的相同钻石,即消去,上面的钻石靠重力落下。
5、祖玛(Zuma)
一款休闲益智游戏,玩法很像QQ龙珠,将中间吐出来的珠子向着周围连环滚出的同色珠子射打,够三个就能炸裂消除,简单有趣。
想要了解更多有关Java开发的相关信息,推荐咨询千锋教育。千锋教育总部位于北京,目前已在20个城市成立分公司,现有教研讲师团队300余人。公司目前已与国内20000余家IT相关企业建立人才输送合作关系,每年培养泛IT人才近2万人,十年间累计培养超10余万泛IT人才,累计向互联网输出免费教学视频950余套,累积播放量超9800万余次,实力强大,值得选择。
C. 用Java可以做哪些有趣的事情
像Instrial Light and Magic这样的公司,就依赖Java来满足各种编程需求。事实上,你经常可以在ILM上发现几乎任何有开发需要的工作。在ILM工作有意思的地方在于,你可以把应用程序一起放到在大屏幕上查看结果。目前,ILM使用Java和Python来处理诸如测序动画场景等任务。
D. 用Java可以做哪些有趣的事情
可以写个公共号,用别人身份证注册,用黑卡绑定,然后再国外使用假信息搞个vps,然后java就派上用场了,写个爬虫自动爬番号,爬引擎,爬种子,爬图片,然后每天晚上11点左右(为什么是这个时间,大家都懂的。)推送给大家,或者直接link到磁力p2p,然后就可以放心大胆的飙车了,再然后请大家赶紧排队刷卡上车。
E. 有没有关于JAVA的一些简单又有趣的程序
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Date;
public class Game extends JFrame {
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(478, 361, 164, 51));
jButton1.setText("重新开始");
jButton1.setVisible(false);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
jButton1.setVisible(false);
jLabel.setVisible(false);
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
reset();
}
});
}
return jButton1;
}
public static void main(String[] args) {
Game game = new Game();
game.start();
game.reset();
game.gogo();
}
public void reset() {
kup = false;
kdown = false;
kleft = false;
kright = false;
int chushihua = 0;
while (chushihua < zidanshu) {
((JButton) buttonal.get(chushihua)).setBounds(new Rectangle(-50,
-50, 10, 10));
chushihua++;
}
gamexunhuan = true;
jButton.setIcon(new ImageIcon(fileLoc));
jButton.setLocation(320, 320);
p = jButton.getLocation();
x=p.getX();
y=p.getY();
firsttime=new Date().getTime();
}
public void start() {
int chushihua = 0;
while (chushihua < zidanshu) {
JButton jb = new JButton();
jb.setBounds(new Rectangle(-50, -50, 10, 10));
jb.setEnabled(false);
Threads ths = new Threads(jb);
Thread th = new Thread(ths);
buttonal.add(jb);
threadal.add(th);
chushihua++;
}
Game.Move move = new Move();
Thread tm = new Thread(move);
tm.start();
}
public void gogo() {
int chushihua = 0;
while (chushihua < zidanshu) {
((Thread) threadal.get(chushihua)).start();
chushihua++;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
// private static Game game;
private long firsttime;
private long lasttime;
private static final long serialVersionUID = 1L;
private JPanel jPanel = null;
private JButton jButton = null;
private boolean kup ;
private boolean kdown ;
private boolean kleft ;
private boolean kright ;
// 定义玩家的行走步伐,数值越大,移动速度越快 private int step = 3;
Point p; // @jve:decl-index=0:
double x = 0.0;
double y = 0.0;
// 定义了子弹的个数 int zidanshu = 70;
// 定义子弹初始值,这个是不变的
// int chushihua = 0;
// 定义控制子弹行走的循环false就不走了
private boolean gamexunhuan = true;
private JLabel jLabel = null;
private JButton jButton1 = null;
private ArrayList buttonal = new ArrayList();
private ArrayList threadal = new ArrayList();
URLClassLoader urlLoader = (URLClassLoader)this.getClass().getClassLoader();
URL fileLoc = urlLoader.findResource("MyGameIcons/gwl1.gif"); // @jve:decl-index=0:
URL fileLoc1 = urlLoader.findResource("MyGameIcons/gwls1.gif");
/**
* This is the default constructor
*/
public Game() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(700, 700);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(1);
}
});
this.setResizable(false);
this.setContentPane(getJPanel());
this.setTitle("范传奇的小游戏!(模拟撑过30秒的小DEMO)");
this.setVisible(true);
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(42, -33, 595, 308));
jLabel.setFont(new Font("Dialog", Font.BOLD, 24));
jLabel.setForeground(new Color(250, 2, 2));
jLabel.setEnabled(true);
jLabel.setVisible(false);
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.add(getJButton(), null);
jPanel.setForeground(new Color(1, 1, 1));
jPanel.setBackground(new Color(1, 1, 1));
jPanel.setVisible(true);
jPanel.add(jLabel, null);
jPanel.add(getJButton1(), null);
}
return jPanel;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
class Move implements Runnable {
public void run() {
while(true){
while (gamexunhuan) {
p = jButton.getLocation();
if (kup) {
if (kleft) {
x = p.getX();
y = p.getY();
if (x > 0 && y > 0) {
jButton.setLocation((int) x - step, (int) y
- step);
}
} else if (kright) {
x = p.getX();
y = p.getY();
if (x + 40 < 700 && y > 0) {
jButton.setLocation((int) x + step, (int) y
- step);
}
} else {
x = p.getX();
y = p.getY();
if (y > 0) {
jButton.setLocation((int) x, (int) y - step);
}
}
}
if (kdown) {
if (kleft) {
x = p.getX();
y = p.getY();
if (y + 60 < 700 && x > 0) {
jButton.setLocation((int) x - step, (int) y
+ step);
}
} else if (kright) {
x = p.getX();
y = p.getY();
if (x + 40 < 700 && y + 60 < 700) {
jButton.setLocation((int) x + step, (int) y
+ step);
}
} else {
x = p.getX();
y = p.getY();
if (y + 60 < 700) {
jButton.setLocation((int) x, (int) y + step);
}
}
}
if (kleft) {
if (kup) {
x = p.getX();
y = p.getY();
if (x > 0 && y > 0) {
jButton.setLocation((int) x - step, (int) y
- step);
}
} else if (kdown) {
x = p.getX();
y = p.getY();
if (y + 60 < 700 && x > 0) {
jButton.setLocation((int) x - step, (int) y
+ step);
}
} else {
x = p.getX();
y = p.getY();
if (x > 0) {
jButton.setLocation((int) x - step, (int) y);
}
}
}
if (kright) {
if (kup) {
x = p.getX();
y = p.getY();
if (x + 40 < 700 && y > 0) {
jButton.setLocation((int) x + step, (int) y
- step);
}
} else if (kdown) {
x = p.getX();
y = p.getY();
if (x + 40 < 700 && y + 60 < 700) {
jButton.setLocation((int) x + step, (int) y
+ step);
}
} else {
x = p.getX();
y = p.getY();
if (x + 40 < 700) {
jButton.setLocation((int) x + step, (int) y);
}
}
}
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
}
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(320, 320, 30, 30));
jButton.setBackground(new Color(1, 1, 1));
p = jButton.getLocation();
x = p.getX();
y = p.getY();
jButton.setIcon(new ImageIcon(fileLoc));
jButton.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent e) {
if(e.getKeyCode()==10){
if(!gamexunhuan){
jButton1.setVisible(false);
jLabel.setVisible(false);
reset();
}
}
if (e.getKeyCode() == 37) {
kleft = false;
}
if (e.getKeyCode() == 38) {
kup = false;
}
if (e.getKeyCode() == 39) {
kright = false;
}
if (e.getKeyCode() == 40) {
kdown = false;
}
}
public void keyPressed(java.awt.event.KeyEvent e) {
if (e.getKeyCode() == 37) {
kleft = true;
}
if (e.getKeyCode() == 38) {
kup = true;
}
// 触发按右键
if (e.getKeyCode() == 39) {
kright = true;
}
if (e.getKeyCode() == 40) {
kdown = true;
}
}
});
}
return jButton;
}
class Threads implements Runnable {
public Threads(JButton jjb) {
jb = jjb;
}
JButton jb = null;
private boolean first = true;
public void run() {
while (gamexunhuan) {
go();
}
}
public void go() {
int zzx = 0;
int zzy = 0;
int zx = 0;
int zy = 0;
while (true) {
if(gamexunhuan){
int fangxiang = (int) (Math.random() * 4 + 1);
// 四个if随即从四个边发射子弹
if (fangxiang == 1) {
zx = 0;
zy = (int) (Math.random() * 701);
}
if (fangxiang == 2) {
zx = (int) (Math.random() * 701);
zy = 0;
}
if (fangxiang == 3) {
zx = 700;
zy = (int) (Math.random() * 701);
}
if (fangxiang == 4) {
zx = (int) (Math.random() * 701);
zy = 700;
}
// 初始化子弹,有了就不在加了
if (first) {
jPanel.add(jb, null);
first = false;
}
jb.setBounds(new Rectangle(zx, zy, 10, 10));
// 定义子弹与物体之间的步长
zzx = (int) (((x + 15) - zx) / 30);
zzy = (int) (((y + 15) - zy) / 30);
}
while (gamexunhuan) {
try {
zx += zzx;
zy += zzy;
jb.setLocation(zx, zy);
if (zx + 5 > x & zx + 5 < x + 30 & zy + 5 > y
& zy + 5 < y + 30) {
jButton.setIcon(new ImageIcon(fileLoc1));
gamexunhuan = false;
first = true;
jButton1.setVisible(true);
jLabel.setVisible(true);
lasttime = new Date().getTime();
Date gametime = new Date(lasttime-firsttime);
int min =0;
int sec =0;
min = gametime.getMinutes();
sec = gametime.getSeconds();
String endtime = "";
if(min!=0){
endtime=min + "分 " + sec + "秒";
}else{
endtime=sec + "秒";
}
jLabel.setText(" GAME OVER!!! \n用时:" + endtime);
break;
}
// 超出边线停止循环
if (zx > 700 | zy > 700 | zx < 0 | zy < 0) {
break;
}
Thread.sleep(60);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
}
} // @jve:decl-index=0:visual-constraint="10,10"
这是一个以前写过的“是男人就撑过30秒的小游戏源码”
如果想要执行程序,麻烦留个邮箱。
F. 求一个简单又有趣的JAVA小游戏代码
具体如下:
连连看的小源码
package Lianliankan;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戏按钮数组
JButton exitButton,resetButton,newlyButton; //退出,重列,重新开始按钮
JLabel fractionLable=new JLabel("0"); //分数标签
JButton firstButton,secondButton; //
分别记录两次被选中的按钮
int grid[][] = new int[8][7];//储存游戏按钮位置
static boolean pressInformation=false; //判断是否有按钮被选中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戏按钮的位置坐标
int i,j,k,n;//消除方法控制
代码(code)是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。
对于字符和Unicode数据的位模式的定义,此模式代表特定字母、数字或符号(例如 0x20 代表一个空格,而 0x74 代表字符“t”)。一些数据类型每个字符使用一个字节;每个字节可以具有 256 个不同的位模式中的一个模式。
在计算机中,字符由不同的位模式(ON 或 OFF)表示。每个字节有 8 位,这 8 位可以有 256 种不同的 ON 和 OFF 组合模式。对于使用 1 个字节存储每个字符的程序,通过给每个位模式指派字符可表示最多 256 个不同的字符。2 个字节有 16 位,这 16 位可以有 65,536 种唯一的 ON 和 OFF 组合模式。使用 2 个字节表示每个字符的程序可表示最多 65,536 个字符。
单字节代码页是字符定义,这些字符映射到每个字节可能有的 256 种位模式中的每一种。代码页定义大小写字符、数字、符号以及 !、@、#、% 等特殊字符的位模式。每种欧洲语言(如德语和西班牙语)都有各自的单字节代码页。
虽然用于表示 A 到 Z 拉丁字母表字符的位模式在所有的代码页中都相同,但用于表示重音字符(如"é"和"á")的位模式在不同的代码页中却不同。如果在运行不同代码页的计算机间交换数据,必须将所有字符数据由发送计算机的代码页转换为接收计算机的代码页。如果源数据中的扩展字符在接收计算机的代码页中未定义,那么数据将丢失。
如果某个数据库为来自许多不同国家的客户端提供服务,则很难为该数据库选择这样一种代码页,使其包括所有客户端计算机所需的全部扩展字符。而且,在代码页间不停地转换需要花费大量的处理时间。
G. 推荐几个好玩的java游戏
深海鱼鹰
故事发生在一个遥远的行星上,那里完全被水体覆盖,生物都是类似潜水艇的东西。你在海军服役,要进行一系列任务,从探索资源到军事行动。叛军、海岛以及神秘种族的多方交战让你身处险境。
浴火银河3D
把玩家带入了未来40世纪的一个充满了斗争与冲突的太阳系。在凶残的Vossk帝国的带领下,人类已经移民到银河系的每个角落,并发现了其他星系的外星人。其中一些外星人和Vossk帝国的舰队结盟了。
在这场壮丽的战斗中,你可以挑选20种不同的宇宙飞船,G.O.F技术使3D画面处理起来更快;游戏中也融合了太阳系之间的交易元素。你可以在500个星球和空间站之间进行一段漫长而又有趣的旅程。
风云指挥官3D
一款3D多玩家飞行射击游戏,讲述了一个震撼人心的发生在朵朵白云中间的空战以及深深峡谷中的快速追逐射击。玩家的任务是搜寻和摧毁敌对目标,或者护送己方机队通过地方领空。在多玩家模式下,可以在峡谷飞行关口挑战其他玩家,得到最好的排名。
武装空袭
这是个街机式的射击游戏,拥有武器加强、防护盾和修护等先进的空战特点,在横跨三大场景(森林、沙漠、岛屿)的21个任务中,玩家得消灭各种空中和陆地的敌人,并且解救战俘。每个关卡都有一大帮的敌人等着您,而每个场景最终都有个大王阻拦您的去路!
一路狂飚3D
它基于当今最先进的java 3D游戏引擎ABYSS,所以3D效果堪称完美。无论是赛车还是街道,让人有身临其境之感。游戏提供了四辆外型和性能都不同的汽车,并允许任意的变换赛车的颜色。游戏具有情节,并不是单纯的赛车,除了和对手竞速外,还需要按时完成一些任务,大多是在限定的时间开车到城市的某处取物品。你还可以在自由任务中自由自在的在夜晚的城市中开车而无需受到任何限制,不过最好还是避开警车。
机器人联盟3D
是世界上第一款通过移动网络联机的多人3D射击游戏。它将大批的手机玩家引入到永不停息的战斗当中。游戏拥有变化多样的场景,栩栩如生的3D人物,多人游戏模式,将快速动作游戏同在线游戏融为一体。
极速精灵3D
一款富挑战性的3D多人赛车游戏。你要有高超的车技才能在比赛中获得较高的名次。在扭转的沿海赛道上飞驰,欣赏法国海滨的入画风景。真实的物理引擎和杰出的3D画面将带给你非常的赛车体验!惊险赛道,立体感的画面,手感强,快来挑战速度的***。
3D虚拟拉力赛
提供令人眩目的3D图像效果,在3个不同的危险地区有12条不同的路面。通过你的努力在冠军模式中获得冠军,来解锁隐藏的赛车和赛道。在多人对战模式中,和你的对手挑战驾驶技巧,然后在比赛找到取得V-Rally 3D赛车冠军的快乐
Powerboat Challenge
游戏大小: 781 KB 游戏类别: 赛车竞速 游戏界面: 国外软件 英文 运行平台: 204*320版本 浏览次数: 更新时间: 2008-03-26 游戏简介:一款期待已久的240X320赛艇游戏!
Rally Master Pro
竞速类游戏一直是游戏品种中最受欢迎的一类游戏,在这一类产品中,各个厂商为了吸引广大用户纷纷投入不少精力进行研发,竞速类游戏也是我们一直关注的重点品种,日前由Fishlabs出品的一款Rally Master Pro赛车游戏开始浮出水面,已经有不少国外媒体将其推荐为08年度不可不玩的手机游戏,我们也搞到了这款游戏的展示版,大家可以抢先体验下手机上速度与激情的感觉,不过遗憾的是这款游戏对机器性能要求颇高。
魔法利刃
输入58060可以成为完整版。世界上首款3D的MMORPG手机游戏,在庞大的奇幻世界里面,玩家可以选择自己喜欢的角色,去和如兽人和精灵等各种NPC对战,甚至还可以和来自全世界的玩家对战。当玩家穿越大陆去为自己的前路奋战的时候,经验和金钱可以为玩家带来丰富的技能和武器。
H. 一个有趣的Java问题
我用的是扩展思想
以4为例
(1)n=1时,子集是{{1},{2},{3},{4}}
(2)n=2时,在n=1的基础上增加,取n=1每个子集中的最大数max,如果还有数 比这个max大,说明这个子集可以扩展
{1}改为 {1,2},{1,3},{1,4}(max=1)
{2}改为 {2,3},{2,4} (max=2)
{3}改为 {3,4} (max=3)
{4}由于没有数比max大,所以删除{4} (max=4)
这样得到的结果是{{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}}
(3)n=3时,在n=2的基础上增加,取n=2每个子集的最大数
{1,2}改为{1,2,3},{1,2,4} (max=2)
{1,3}改为{1,3,4} (max=3)
{1,4}删除 (max=4)
{2,3}改为{2,3,4} (max=3)
{2,4}删除 (max=4)
{3,4}删除 (max=4)
这样得到的结果是{{1,2,3},{1,2,4},{1,3,4},{2,3,4}}
(4)n=4时,在n=3的基础上修改,很明显,只有{1,2,3}能扩展
所以n=4时的子集是{{1,2,3,4}}
我的设计思想就是这样
下面是原代码
import java.util.Vector;
public class SubSet{
public static void main(String[] args){
int baseNumber=5;
Vector<Vector> all=new Vector<Vector>();
StringBuffer sb=new StringBuffer();
for(int i=1;i<=baseNumber;i++){//外层循环控制子集组合的个数
Vector inner=new Vector();
sb.append(i);
if(i<baseNumber)
sb.append(",");
inner.add(i);
if(i<baseNumber)
all.add(inner);
}
System.out.println(sb.toString());
System.out.println("size="+baseNumber);
for(int i=2;i<=baseNumber;i++){//控制基数
int size=all.size();
for(int j=0;j<size;j++){
Vector temp=(Vector)all.get(j);
int last=(Integer)temp.lastElement();
for(int k=last+1;k<=baseNumber;k++){
Vector added=new Vector(temp);
added.add(k);
all.add(added);
}
}
// System.out.println(all);
/// System.out.println(size);
// printVectorVector(all);
for(int n=0;n<size;n++){
all.remove(0);
}
//System.out.println(all);
printVectorVector(all);
System.out.println("size="+all.size());
}
//主循环结束
}
//main() End
static void printVector(Vector v){
StringBuffer sb=new StringBuffer();
for(int i=0;i<v.size();i++){
sb.append(v.get(i));
}
System.out.print(sb.toString());
}
//打印嵌套的Vector
static void printVectorVector(Vector<Vector> vv){
for(int i=0;i<vv.size();i++){
printVector(vv.get(i));
if(i!=vv.size()-1)
System.out.print(",");
}
System.out.println();
}
}