java求高手帮忙编程

作者&投稿:妫朗 (若有异议请与网页底部的电邮联系)
急求一Java编程答案!!!!求高手帮忙~

import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class ReadSudokuValuesIntoArray {
static int sudokuArray[][] = new int[9][9];
public static int[][] readArray() {
int[][] sudoku = new int[9][9];
Scanner sc = null;
try {
int i = 0, j = 0, count = 1;
sc = new Scanner(new File("vaildsudoku.txt"));
while (sc.hasNextInt()) {
if ((count % 9) == 0) {
sudoku[i][j] = sc.nextInt();
count++;
i++;
j = 0;
} else {
sudoku[i][j++] = sc.nextInt();
count++;
}
}
} catch (FileNotFoundException fnfe) {
System.out.println("No file found");
System.exit(1);
} finally {
sc.close();
}
return sudoku;
}
public static void printArray(int[][] array) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j] + " ");
}
System.out.println();
}
}
public static boolean rowsAreValid(int[][] array) {
for (int i = 0; i < array.length; i++) {// 每一行
for (int j = 0; j < array.length-1; j++) {
for (int k = j+1; k < array.length; k++) {
if (array[i][j] == array[i][k]) {
return false;
}
}
}
}
return true;
}
public static boolean columsAreValid(int[][] array) {
for (int i = 0; i < array.length; i++) {// 每一行
for (int j = 0; j < array.length-1; j++) {
for (int k = j+1; k < array.length; k++) {
if (array[j][i] == array[k][i]) {
return false;
}
}
}
}
return true;
}
public static boolean regionsAreValid(int[][] array){
int [][] arrayTemp=new int [1][9];
int index=0;
for(int i=0;i<8;i=i+3){
for(int j=0;j<8;j=j+3){
//3*3小区域
for(int m=0;m<3;m++)
for(int n=0;n<3;n++){
arrayTemp[0][index]=array[i+m][j+n];
index++;
}
index=0;
if(!rowsAreValid(arrayTemp)){
return false;
}
}
}
return true;
}
public static boolean puzzleIsValid(){
sudokuArray = readArray();
return rowsAreValid(sudokuArray)&&
columsAreValid(sudokuArray)&&
regionsAreValid(sudokuArray);
}
public static void main(String[] args) {
if (puzzleIsValid()) {
printArray(sudokuArray);
} else {
System.out.println("错误啦");
}
}
}
刚刚写的,看看吧~~

package com.accp;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class NewTest {
// 出现次数最多的单词
String firstWord;
// 出现次数第二的单词
String secondWord;
// 出现次数第三的单词
String thirdWord;

// 出现次数最多的个数
int firstCount;
//出现次数最多的个数
int secondCount;
//出现次数最多的个数
int thirdCount;

// 已经检查过的单词
ArrayList checked = new ArrayList();

public static void main(String[] args) {
NewTest nt = new NewTest();
//文件路径
nt.getMax(nt.getText("c:/1.txt"));

System.out.println("1: 单词: "+nt.firstWord+" 出现次数:"+nt.firstCount);
System.out.println("2: 单词: "+nt.secondWord+" 出现次数:"+nt.secondCount);
System.out.println("3: 单词: "+nt.thirdWord+" 出现次数:"+nt.thirdCount);
}

public String getText(String path){

try {
//这里将文件转换为String
BufferedReader br = new BufferedReader(new FileReader(path));
//这里采用StringBuffer缓冲,提高文件内容连接性能
StringBuffer sb = new StringBuffer();
String temp;
while((temp = br.readLine()) != null){
sb.append(temp);
}
return sb.toString();
} catch (Exception ex) {
System.out.println(ex);
}
return null;
}

public void getMax(String text){
//用空格分割文章
String[] temp = text.split(" ");

//当前检查单词出现个数
int currentMax = 0;
for (int i = 0; i < temp.length; i++) {
//如果是这3个单词则忽略
if(temp[i].equals("a") || temp[i].equals("an") || temp[i].equals("the") || checked.contains(temp[i]))
continue;

//将但前单词和所有单词对比,如果相同则当前单词出现个数加1
for (int j = 0; j < temp.length; j++) {
if(temp[i].equals(temp[j])){
currentMax++;
}
}

//如果当前单词个数比出现次数最多的单词还多,则替换
if(currentMax >= firstCount){
thirdCount = secondCount;
secondCount = firstCount;
firstCount = currentMax;
thirdWord = secondWord;
secondWord = firstWord;
firstWord = temp[i];
}
//如果当前单词个数比出现次数第二的单词还多,则替换
else if(currentMax >= secondCount){
thirdCount = secondCount;
secondCount = currentMax;
thirdWord = secondWord;
secondWord = temp[i];
}
//如果当前单词个数比出现次数第三的单词还多,则替换
else if(currentMax >= thirdCount){
thirdCount = currentMax;
thirdWord = temp[i];
}
//将当前单词添加到已经检查过的单词集合中,并将当前单词出现个数清零
checked.add(temp[i]);
currentMax=0;
}
}
}
这个还要自己多想想,只要你认真思考,其实也很简单的

老兄你也太粗心了吧,哪有每吨每千克的,我都给你给弄晕了`````应该是每吨每千米吧
int price=0;//每吨每千米为price元
int fee=0;//总费用
if(路程<100km){price=1}
else if(路程>=100km && 路程<300km){price=0.9}
else if(路程>=300km && 路程<500km){price=0.8}
else if(路程>=500km && 路程<1000km){price=0.7}
else{price=0.6}
fee = 路程*吨数*price

import java.util.*;
public class Dollar
{
public static void main(String[] args)
{ Scanner x=new Scanner(System.in);
System.out.print("input lucheng:");
int m=Integer.parseInt(x.next());
Scanner y=new Scanner(System.in);
System.out.print("input zhongliang:");
int n=Integer.parseInt(y.next());
int sum=0;
if(m>1000)
{ sum+=0.6*n*m;
}
else
if(m>500)
{ sum+=0.7*n*m;
}
else
if(m>300)
{ sum+=0.8*n*m;
}
else
if(m>100)
{ sum+=0.9*n*m;
}
else
{ sum+=n*m;
}
System.out.println("sum="+sum);
}
}

import java.util.*;
public class Cost {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
Scanner sc1=new Scanner(System.in);
int length=0;
double height=0;
System.out.println("输入路程/千米");
length=sc.nextInt();
double price=pricecost(length);
System.out.println("输入重量/吨");
height=sc1.nextDouble();
double cost=price*height*length;
System.out.println("总费用为"+cost);
}
static double pricecost(int length){
//求价格类
double price=0.0;
if(length<100){
price=1.0;
}
if(length>=100&&length<300){
price=0.9;
}
if(length>=300&&length<500){
price=0.8;
}
if(length>=500&&length<1000){
price=0.7;
}
if(length>=1000){
price=0.6;
}
else{
System.out.println("");

}
return price;
}
}


高分 按键精灵9后台脚本 求大师级帮我 修改一下脚本
Hwnd = Plugin.Window.Find(“LaunchUnrealUWindowsClient”,“Alliance of Valiant Arms”)2个参数都是字符串类型,所以都要加引号。高手按键精灵都是自学的。我连官方的视频教程都没看过。

跪求AVA战地之王,死亡峡谷通关队务.第二个发射器过不去...
简单,菜鸟用连狙过,高手就用M4或AK就可以过,但2者都需配合。电锯男找一个人在墙角卡,但不要开枪,蹲在那里便可,其余人用刀砍围在他身边的电锯,别用枪,后果会很严重。。。

AVA画面不正常.人物模型会闪 有部分会时不时变透明的是怎么回事?_百度...
一楼三楼误导你,没显卡或者显卡有问题都是无法进入游戏的,你把游戏设置里的设置往低调就行了,显卡不太好造成 的现象

我下载了AVA点击进入后,说显卡达不到最低配置,进入
没可能,我以前的台式就是这样,你要不去网吧,要去就不玩,你总不至于为玩游戏换电脑吧

为什么AVA点击开始游戏后什么都没了
屏幕消失后,进不去?打开任务管理器,进程如果找到了Avalau开头的进程,那么只要耐心等待,十分钟内应该进得去.

请教专业射击游戏鼠标设置AVA 配置罗技MX518于以游戏内鼠标速度的关联...
说实话 按你目前“在技术的发挥上普通鼠标是难以达到要求的”只是想知道你用普通鼠标游戏里调速度是多少 合手就可以 MX518速度很快了 所以一般的话就比你平时老鼠标所调的速度少那么五分之二就很舒服了 至少我是这么弄的 这个因人而异 虽然我不是高手 但是这么说吧 这东西光说说是不能说明什么的 ...

AVA自动退出
你配置不够吧。。。你可以换换游戏玩了,就算勉强玩,电脑还是很卡,AVA就是对电脑要求比较高的。。。希望采纳

关于电脑CPU散热和玩AVA之间的问题。。。
既然知道是硅脂了,最好还是去买点来涂上 1.首先用高纯度溶剂如高纯度异戊醇或丙酮和无绒布(如擦镜头用的布)清洗CPU核心和散热器表面(一个指纹可能会厚达0.005英寸左右)。个人觉得这一步可以省略,只要表面干净无油即可。2.确定散热片上与CPU接触的区域,在区域中心挤上足够的散热膏。3.用干净的...

有关AVA 战地之王的安装问题
我敢保证 你的电脑 装了360安全卫士了 先把360安全卫士 完全退出,安装开始后 再开360 就可以了,在这里 随便鄙视一下腾讯。

AVA切为什么会掉
你好,楼主,AVA大部分玩家切换出来多数会有这个问题。在排除电脑配置问题外,我的建议是你把游戏的分辨率调成和你桌面的分辨率一样(通常是1024*768),这样你切换出来一般情况掉线的几率就会小很多,但不针对所以用户,望我的建议对你有所帮助!谢谢采纳!

伊春市13255959700: 求高手编java的程序 -
茶歪参芪: 我帮你完成吧.------------------- 车类的题目:创建包test.car 第一个类:Car.java package test.car;/** * 车类 * @author qinghua9 * 抽像类,定义两个方法 */ public abstract class Car { public void driver(){}; public void stop(){}; } 第二个类Bus.java ...

伊春市13255959700: JAVA编程求帮助 -
茶歪参芪: public class $ { public static void main(String[] args) { new Bean(); } } class Bean { private static int a; static { a = 100 / 0; } public Bean() { System.out.println("创建对象,这句话打印不出来"); } }

伊春市13255959700: 急求JAVA编程高手~~~!
茶歪参芪: import java.util.Scanner; public class haha{ public static void jie(int a,int b) { System.out.print("乘积为:"+(a*b)); } public static void main(String[] args){ Scanner in=new Scanner(System.in); System.out.print("请输入第一个乘数:"); int a=in.nextInt(); System.out.print("请输入第二个乘数:"); int b=in.nextInt(); jie(a,b); } }

伊春市13255959700: 请学java的高手帮忙编辑一个程序
茶歪参芪: public class 点名册{ private String 学生姓名; private int 迟到次数; //TODO 还可以写构造器,方法,按照自己的想法来吧}

伊春市13255959700: 急求高手帮我编java程序,追分的... -
茶歪参芪: 汉诺塔:import java.io.*;public class Hanoi { public static void main(String args[]) throws IOException { int n; InputStreamReader in= new InputStreamRea...

伊春市13255959700: 求编程高手帮我写一个JAVA程序
茶歪参芪: package ddd; public class Dish { private String name; private String id; private double unit; private int number; private String text; public Dish(String id,String name,double unit,int number){ this.id=id; this.name=name; this.unit=unit; this.number=...

伊春市13255959700: java一个简单小程序,求高手帮忙编写,万分感谢 -
茶歪参芪: class Ball { public void play() { System.out.println("玩球儿..."); } } class Football extends Ball { public void play() { System.out.println("使用足球运动"); } } class Basketball extends Ball { public void play() { System.out.println("...

伊春市13255959700: JAVA编程,求高手
茶歪参芪: 第一道: public class getSum { public static void main(String[] args) { int sum = 0; for(int i=1;i<=100;i=i+2) { sum += i; } System.out.println(sum); } }第二: 解法一:public class zhishu { /** *求是否是质数 */ public static void main(String[] args) { // ...

伊春市13255959700: 急急急!!!JAVA - --请java高手帮帮忙!! -
茶歪参芪: public class Animal { private String name; private String height; private String weight; /** * @return the height */ public String getHeight() { return height; } /** * @param height * the height to set */ public void setHeight(String height) { this.height = height;...

伊春市13255959700: 求JAVA高手解决问题,本人是初学者,奉上本人所有金币1. 编程求X的值X=1+1/(1*3)+1/(3*5)+….+1/(2n - 1)*(2n+1)+….要求精确到0.000012.已知一个一个数... -
茶歪参芪:[答案] 第一题和第二题都在一起写着呢,整个类都贴过来了, 第二题也有别人问过,具体解释可以去参考 import java.math.BigDecimal; import java.util.Arrays; publicclass Test { publicstaticvoid main(String[] args) { double x = 0.0d; //求x的值 for (int i = 0; i if(i ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网