What are the deficiencies or questions I would like to be able to get a lot of corrections, thank you
Copy Code code as follows:
Import Java.util.Scanner;
/**
*
* @author CC Example 100 coins, initially all facing down, the first time all coins reversed, the second reversal position is a multiple of 2 coins,
* Third reversal of the multiples of 3,..... Execute 100 times and ask, how many coins are finally facing up?
*
* 1. The positive and negative use of the array 1, 0, 1 for the front, 0 for the opposite;
*
*
* Results of 100 coins
int[] = = 1100100001000000100000000100000000001000000000000100000000000000100000000000000001000000000000000000
Result coin about 1 nums = 10
*/
public class Cointurn {
private static int[] intcoins;
public static void Main (string[] args) {
TODO auto-generated Method Stub
int coinnum = Inputnum ();
Intcoins = new Int[coinnum];
/*
* Initialization
*/
for (int i = 0; i < intcoins.length; i++) {
Intcoins[i] = 0;//initialization all facing down, that is, back 0
}
Doturncoin ();
int resutltcoin = Getcoinnum ();
System.out.println ("Result coin about 1 nums =" + resutltcoin);//output end face upward
}
private static void Doturncoin () {
/*
* Flip Operation
*/
for (int i = 1; i < intcoins.length i++) {//Determine multiples
for (int j = I-1 J < Intcoins.length; J + +) {//Loop flip
If (j% i = = 0) {//coin sequence number is a multiple of the current number, flip
if (intcoins[j] = = 0) {
INTCOINS[J] = 1;
} else {
INTCOINS[J] = 0;
}
}
}
}
}
private static int Getcoinnum () {
int countnum = 0;//record number of final coin front
StringBuffer strb = new StringBuffer ();
for (int a:intcoins) {
Strb.append (A + "");
if (1 = = a)
countnum++;
}
System.out.println ("int[] = =" + STRB);//output array result
return countnum;
}
/*
* Coin number
*/
private static int Inputnum () {
System.out.println ("Input coin num:");
Scanner input = new Scanner (system.in);
return Input.nextint ();
}
}