第一题:
import java.util.Random;
public class Demo3 {
/**
* @param args
*/
private int i [] ;//定义数组i;
private Random random;//引用随机类型;
public Demo3(){
i=new int [10];
random=new Random();
Test();
}
public void Test(){
//给int数组赋值;
for (int a=0;a<10;a++){
i[a]=random.nextInt(100);
}
//加入判断如果有重复则重新赋值
for(int a=0;a<10;a++){
for (int b=0;b<10;)
if(i[a]==i[++b]){
i[a]=random.nextInt(100);
}
else{
continue;
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Demo3();
}
}
第二题:
import java.util.Scanner;
public class Demo3 {
/**
* @param args
*/
private String stu;//实例化String
private Scanner input;//实例化 input
public Demo3(){
//对实例化变量进行初始化
input=new Scanner(System.in);
stu=input.next();
Test();
}
public void Test(){
String ss;
//从最后一个开始循环输出字符串;
for (int a=stu.length();a>0;a--)
System.out.print(stu.charAt(a-1));
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new Demo3();
}
}
public class User {
private int userID;
private String userName;
private String password;
private String IDcard;
private String email;
private String sex;
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getIDcard() {
return IDcard;
}
public void setIDcard(String IDcard) {
this.IDcard = IDcard;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String toString(){
return userID+userName+password+IDcard+email+sex;
}
}
没分数啊兄弟 你这个也不是一两行代码的问题