大佬帮助写代码java 教你写代码
(Java)求大佬帮忙写一下
import java.util.*;
我们提供的服务有:成都网站制作、做网站、外贸营销网站建设、微信公众号开发、网站优化、网站认证、白碱滩ssl等。为成百上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的白碱滩网站制作公司
public class interView {
public static void main(String[] args) {
System.out.println("输入第一个String类型:");
String a = null;
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
a = cin.nextLine();
break;
}
System.out.println("输入第二个String类型:");
String b = null;
Scanner cin1 = new Scanner(System.in);
while (cin.hasNext()) {
b = cin.nextLine();
break;
}
Remainder ss = new Remainder();
ss.getRemainder(a, b);
}
public static class Remainder {
public void getRemainder(String a, String b) {
int i = Integer.parseInt(a);
int j = Integer.parseInt(b);
try {
int n = i / j;
System.out.println("两个数的商:" + n);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
结果如下: 1、NumberFormatException
2、ArithmeticException
3、正常
求大佬帮助写这条Java代码
public class Person {
public String name;
public int age;
public Person(String name, int age){
this.name = name;
this.age = age;
}
public Person(String name){
this.name = name;
this.age = 20;
}
public void work(){
System.out.println("我正在工作!");
}
public static void main(String[] args) {
Person p = new Person("I");
p.work();
}
}
-------------------------------------------------------------
public class Person {
public String name;
public int age;
public Person(String name, int age){
this(name);
this.age = age;
}
public Person(String name){
this.name = name;
this.age = 20;
}
public void work(){
System.out.println("我正在工作!");
}
public static void main(String[] args) {
Person p = new Person("I");
p.work();
}
}
class Student extends Person{
public Student(String name){
super(name);
}
public void work(){
System.out.println("学生在学习!");
}
}
class Teacher extends Person{
public Teacher(String name){
super(name);
}
public void work(){
System.out.println("老师在授课!");
}
}
大佬求帮助写这条Java代码,急
package test1;
import java.util.Scanner;
public class Test {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("输入数组1长度");
int n1 = scanner.nextInt();
System.out.println("输入数组1");
String nullString1 = scanner.nextLine();
String numsString1 = scanner.nextLine();
String[] split1 = numsString1.split(" ");
System.out.println("输入数组2长度");
int n2 = scanner.nextInt();
System.out.println("输入数组2");
String nullString2 = scanner.nextLine();
String numsString2 = scanner.nextLine();
String[] split2 = numsString2.split(" ");
System.out.println("输入条件");
String numsString3 = scanner.nextLine();
String[] split3 = numsString3.split(" ");
int start = Integer.valueOf(split3[0]);
int mubiao = Integer.valueOf(split3[1]);
int number = Integer.valueOf(split3[2]);
for(int i = (mubiao-1),y=(start-1),c = 0 ; c number ; i++,y++,c++){
split1[y] = split2[i];
}
for(int i =0 ; i split1.length ; i++){
System.out.print(split1[i]+" ");
}
}
}
急求大佬帮忙写一下java程序
递归的话就是深度优先搜索(可以理解成不撞南墙不回头,撞了墙就原路返回)可以加上剪枝(就是做标记,如果之前某一次走过但不通的路下次再走到就不用走了)
用栈的话应该是广度优先搜索(大概就是分裂无数个你,每次向所有方向走一步),不过广搜要用队列实现,用栈本质还是深搜了
具体算法可以搜百度
请大佬帮助我写一下这个java程序!!
按照题目要求编写的复数类的Java程序如下
public class Complex{
private float rp;
private float ip;
public Complex(float r ,float i){
rp = r;
ip = i;
}
public Complex() {
rp = 0;
ip = 0;
}
public Complex add(Complex c1 , Complex c2){
rp = c1.rp + c2.rp;
ip = c1.ip + c2.ip;
return this;
}
public Complex subtract( Complex c1,Complex c2){
rp = c1.rp - c2.rp;
ip = c1.ip - c2.ip;
return this;
}
public Complex multiply(Complex c1, Complex c2){
rp = c1.rp*c2.rp - c1.ip*c2.ip;
ip = c1.rp*c2.ip + c1.ip*c2.rp;
return this;
}
public void printComplex(){
System.out.println("("+this.rp+","+this.ip+")");
}
}
网站栏目:大佬帮助写代码java 教你写代码
文章起源:http://hbruida.cn/article/hpphio.html