qingzhipan027
发贴: 1
积分: 0
|
于 2006-05-22 11:49
我改了下,语法上没什么问题了,可是好像执行不了…… import java.io.*; public class t { static String str1[]={"A","B","C","D"}; static String str2[][]={{"*","*","*","*"},{"*","*","*","*"},{"*","*","*","*"},{"*","*","*","*"}}; public static void main(String args[])throws IOException {
int bA; String b1,b2,b3,b4,c1,c2,c3,c4;
BufferedReader aIn=new BufferedReader(new InputStreamReader(System.in));
//输入A System.out.println("A说:"); b1=aIn.readLine(); bA=Integer.parseInt(b1); c1=aIn.readLine(); String g = c1.substring(0,0); hanshu(bA,g);//函数调用
System.out.println("B说:"); b2=aIn.readLine(); bA=Integer.parseInt(b2); c2=aIn.readLine(); String g2 = c2.substring(0,0); hanshu(bA,g2);//函数调用
System.out.println("C说:"); b3=aIn.readLine(); bA=Integer.parseInt(b3); c3=aIn.readLine(); String g3 = c3.substring(0,0); hanshu(bA,g3);//函数调用
System.out.println("D说:"); b4=aIn.readLine(); bA=Integer.parseInt(b4); c4=aIn.readLine(); String g4 = c4.substring(0,0); hanshu(bA,g4);//函数调用
//bA和c的输出 System.out.println(bA); System.out.println();
//数组输出 for(int i=0;i<4;i++) System.out.print(str1[i]+" "); System.out.println("\n"); for(int i=0;i<4;i++) { System.out.println("\n"); for(int j=0;j<4;j++) System.out.print(str2[i][j]+" "); } } //函数 static void hanshu(int x,String y) { String comp; comp=y; int k=0; switch(x) { case 0: for(int i=0;i<4;i++) { if(comp.equals(str1[i])) str2[k][i]="*"; else str2[k][i]=str1[i]; } k++; break; case 1: for(int i=0;i<4;i++) { if(comp.equals(str1[i])) str2[k][i]=str1[i]; else str2[k][i]="*"; } k++; break; } } }
why edited on 2006-05-22 12:32
|