After-school archive 6

Source: Internet
Author: User

A. Gobang plate

using a two-dimensional array to output a 15*15 Checkerboard, the original of the board is "+", is the output of a horizontal longitudinal is a "+ ", and then enter the pawn""in the form of coordinates, replacing the"+" in the original chessboard . Then write whether the game ends with code.

Two Digital Conversions

Source:

import Java.util.Scanner;

Public class Zhuanhuan

{

Private String[] Hanarr = {" 0 " , "one", "two", "three", "four",

"Five", "six", "seven", "eight", "Nine"};

Private String[] Unitarr = {" 10 " , " hundred ", " thousand ", " million ", " 100,000 "," million "};

Private String Tohanstr (String numstr)

{

String result = "";

int Numlen = Numstr.length ();

for (int i = 0; i < Numlen; i++)

{

int num = Numstr.charat (i)-48;

if (I! = numLen-1 && num! = 0)

{

Result + = Hanarr[num] + unitarr[numlen-2-i];

}

Else

{

if (Result.length () >0 && hanarr[num].equals (" 0 ") && Result.charat (Result.length ( )-1) = = ' 0 ')

continue;

Result + = Hanarr[num];

}

}

if (Result.length () ==1)

return result;

int index=result.length ()-1;

while (Result.charat (index) = = ' 0 ')

{

index--;

}

if (Index!=result.length ()-1)

return result.substring (0,index+1);

Else

{

return result;

}

}

Public Static void Main (string[] args)

{

Zhuanhuan nr = new Zhuanhuan ();

System. out. println (" only supports integers (0~ million)");

Scanner Scanner = new Scanner (System. in);

System. out. println (" Please enter an integer under million:");

String str = Scanner.next ();

System. out. println (Nr.tohanstr (str));

}

}

Operation Result:

Three Large number

Source:

import Java.util.Scanner;

Public class Dashu

{

Public Static void Main (String args[])

{

System. out. println (" Please enter the first number:");

Scanner Scanner = new Scanner (System. in);

String input1 = Scanner.next ();

System. out. println (" Please enter a second number:");

String input2 = Scanner.next ();

int [] Number1 = new int[100];

int [] number2 = new int[100];

int [] Number3 = new int[100];

int [] number4 = new int[100];

int a = 0;

int b = 0;

for (int i = input1.length ()-1; I >= 0; i--)

{

int number = Input1.charat (i)-48;

Number1[a] = number;

a++;

}

for (int i = input2.length ()-1; I >= 0; i--)

{

int number = Input2.charat (i)-48;

NUMBER2[B] = number;

b++;

}

if (Input1.length () > Input2.length ())

{

for (int i = 0; i < b; i++)

{

Number3[i] = Number1[i] + number2[i];

}

for (int i = b; i < A; i++)

{

Number3[i] = Number1[i];

}

for (int i = input1.length ()-2; I >= 0; i--)

{

if (number3[i]>9)

{

Number3[i] = number3[i]-10;

Number3[i + 1] = Number3[i + 1] + 1;

}

}

System. out. println ("The sum of two numbers added is:");

for (int i = input1.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

Else if (Input1.length () <input2.length ())

{

for (int i = 0; i < A; i++)

{

Number3[i] = Number1[i] + number2[i];

}

for (int i = A; I < b; i++)

{

Number3[i] = Number2[i];

}

for (int i = input2.length ()-1; I >= 0; i--)

{

if (number3[i]>9)

{

Number3[i] = number3[i]-10;

Number3[i + 1] = Number3[i + 1] + 1;

}

}

System. out. println ("The sum of two numbers added is:");

for (int i = input2.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

Else

{

for (int i = 0; i < A; i++)

{

Number3[i] = Number1[i] + number2[i];

}

for (int i = input2.length ()-2; I >= 0; i--)

{

if (number3[i]>9)

{

Number3[i] = number3[i]-10;

Number3[i + 1] = Number3[i + 1] + 1;

}

if (Number3[input2.length ()-1] > 9)

{

}

}

System. out. println ("The sum of two numbers added is:");

for (int i = input2.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

System. out. println ();

if (Input1.length () > Input2.length ())

{

for (int i = 0; i < b; i++)

{

Number3[i] = Number1[i]-number2[i];

}

for (int i = b; i < A; i++)

{

Number3[i] = Number1[i];

}

for (int i = input1.length ()-1; I >= 0; i--)

{

if (Number3[i] < 0)

{

Number3[i] = Number3[i] + 10;

Number3[i + 1] = number3[i + 1]-1;

}

}

if (Number3[input1.length ()-1] = = 0)

{

System. out. println ("The difference between the first number minus the second number is:");

for (int i = input1.length ()-2; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

Else

{

System. out. println ("The difference between the first number minus the second number is:");

for (int i = input1.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

}

Else if (Input1.length () < Input2.length ())

{

for (int i = 0; i < A; i++)

{

Number3[i] = Number2[i]-number1[i];

}

for (int i = A; I < b; i++)

{

Number3[i] = Number2[i];

}

for (int i = input2.length ()-1; I >= 0; i--)

{

if (Number3[i] < 0)

{

Number3[i] = Number3[i] + 10;

Number3[i + 1] = number3[i + 1]-1;

}

}

if (Number3[input2.length ()-1] = = 0)

{

System. out. println ("The difference between the first number minus the second number is:");

System. out. Print ("-");

for (int i = input2.length ()-2; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

Else

{

System. out. println ("The difference between the first number minus the second number is:");

System. out. Print ("-");

for (int i = input2.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

}

Else

{

for (int i = 0; i < A; i++)

{

Number3[i] = Number1[i]-number2[i];

}

for (int i = input2.length ()-2; I >= 0; i--)

{

if (Number3[i] < 0)

{

Number3[i] = Number3[i] + 10;

Number3[i + 1] = number3[i + 1]-1;

}

}

if (Number3[input2.length ()-1] = = 0)

{

System. out. println ("The difference between the first number minus the second number is:");

for (int i = input2.length ()-2; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

Else

{

System. out. println ("The difference between the first number minus the second number is:");

for (int i = input2.length ()-1; I >= 0; i--)

{

System. out. Print (Number3[i]);

}

}

}

}

}

Operation Result:

four . array random number

After-school archive 6

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.