Java Internship One

Source: Internet
Author: User

Simple one-time equation solution of two yuan
Import Java.lang.math;import Java.util.scanner;public class solve{public static void Main (String args[]) {Scann        ER reader = new Scanner (system.in);        int a = Reader.nextint ();        int b = Reader.nextint ();        int c = Reader.nextint ();        Double ans1 = 0.0, ans2 = 0.0;        Double det = b * b-4 * a * C;            if (a = = 0 && b! = 0) {System.out.println ("the equation has only one root:" + -1*c/b);        return;            } if (a = = 0 && b = = 0) {System.out.println ("no solution");        return;            } if (Det < 0) {System.out.println ("no solution");        return;            } else if (Det = = 0) {ans1 = -1*b/(2*a);        System.out.println ("There is only one root of the equation:" + ans1);            }else{det = math.sqrt (det);            ans1 = -1*b + det;            Ans1/= 2.0*a;            Ans2 = -1*b-det;            Ans2/= 2.0*a;            SYSTEM.OUT.PRINTLN ("There are only two of these equations:"); System.out.println ("The first rootFor: "+ ans1);        System.out.println ("The second root is:" + ans2); }    }    }
Simple class of students
Package Student;import java.lang.string;import java.util.scanner;class schoolstudent{String name;      int grade;        void Set (String name, int grade) {this.name = name;    This.grade = grade;        } schoolstudent Get (Schoolstudent st) {st.name = THIS.name;        St.grade = This.grade;    Return St;        } schoolstudent (String name, int grade) {this.name = name;    This.grade = grade;        } schoolstudent () {this.name = "";    This.grade = 0; }} public class student{public static void Main (String args[]) {while (true) {Scanner                reader = new Scanner (system.in);                System.out.println ("Name:");                String name = Reader.nextline ();                System.out.println ("Score:");                int grade = Reader.nextint ();                Schoolstudent tom = new Schoolstudent (Name,grade);                System.out.println ("Student Name:" + tom.name); System.out.println ("Score:" + Tom.)grade); }               }   }
Gobang Gobang File
Import Java.util.scanner;public class wuziqi{static int maxn = 16;    private static char[][] map = new CHAR[MAXN][MAXN];    private static char[] baihei= {' 0 ', '};    private static int[] Tox = { -1,0,-1,-1,1,1,0,1};    private static int[] toy = {0,-1,-1,1,-1,1,1,0};                public static void Init () {for (Int. I=1; i<maxn; i++) for (int j=1; j<maxn; j + +)    MAP[I][J] = ' + ';            public static void Paint () {for (Int. I=1; i<maxn; i++) {for (int j=1; j<maxn; j + +)            {System.out.print (map[i][j]);        } System.out.println ();            }} public static Boolean islegal (int i, int j) {if (i>15 | | i<1 | | j>15 | | j<1) {        return false;    } return true;            } private static int iswin (int p,int x,int y) {for (int i=0; i<4; i++) {int sum = 1;            int xx = x+tox[i]; int yy = Y+toY[i];                while (map[xx][yy]==baihei[p%2] && islegal (xx,yy)) {sum++;                xx = Xx+tox[i];            yy = Yy+toy[i];            } xx = X+tox[7-i];            yy = Y+toy[7-i];                while (map[xx][yy]==baihei[p%2] && islegal (xx,yy)) {sum++;                xx = Xx+tox[7-i];            yy = Yy+toy[7-i];        } if (sum>=5) return 1;    } return 0;        } public static void Main (string[] args) {init (); int cnt =-1;            He while (true) {System.out.println ("Enter the coordinates of the falling chess, in the form of X y:");            Scanner reader = new Scanner (system.in);            int x1 = Reader.nextint ();            int y1 = Reader.nextint ();                while (!islegal (x1,y1) | | map[x1][y1]! = ' + ') {System.out.println ("Please re-enter the coordinates of the Falling Chess:");                reader = new Scanner (system.in); X1 = Reader.nextInt ();            Y1 = Reader.nextint ();            } cnt++;            MAP[X1][Y1] = baihei[cnt%2];            Paint ();                if (Iswin (cnt,x1,y1) ==1) {System.out.println ("Congratulations on winning");            Break                } if (cnt = = 15*15-1) {System.out.println ("draw");            Break }        }    }}

Java Internship one

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.