package sz; import java.awt.Button; import java.awt.Frame; import java.awt.Label; import java.awt.TextField; import java.util.Random; public class Jsq { Frame frame = new Frame("四则运算"); frame.setVisible(true); String one=""; String second=""; String[] str=new String[10]; String[] stb=new String[10]; public String tiMu() { char[] ch = new char[] { ‘+‘, ‘-‘, ‘*‘, ‘/‘ }; int a; int b; char c; Random r = new Random(); boolean suiji = true; while (suiji) { a = r.nextInt(11); b = r.nextInt(11); c = ch[r.nextInt(ch.length)]; } final TextField one = new TextField(10); final TextField second = new TextField(10); Label label = new Label("="); final TextField three = new TextField(10); Button button = new Button("计算"); } public void tiShi() { for(int i=0;i<10;i++) { tiMu(); str[i]=one; stb[i]=second; one=""; second=""; for(int j=0;j<i;j++) { if(str[j]==str[i]||str[j]==stb[i] } System.out.println("第"+(i+1)+"题:"+str[i]); } } public static void main(String[] args) { Jsq js=new Jsq(); js.tiShi(); } }
总结:实践出真知,第一次自己研究代码,参考了网上的资料,有些代码看不懂,暂时就写这样吧,下次会继续研究下,把代码完善,希望老师不要介意。谢谢老师!
原文:http://www.cnblogs.com/wen2020/p/4857971.html