There are four numbers 1, 2, 3, and 4. How many different three-digit numbers can be formed without repeated numbers? How many are they?
public class Pratice2_1_6
{
public static void main(String[] args){
int ln=0;
for(int i='1'; i<='4'; i++)
for(int j='1'; j<='4'; j++)
for(int k='1'; k<='4'; k++)
{
if(i!=j && i!=k && j!=k){
System.out.print(""+(char)i+(char)j+(char)k+" ");
ln++;
}
if(ln == 6){
System.out.println();
ln=0;
}
}
}
}
Two table tennis teams compete, each with three players. Team A is composed of a, b, and c, and Team B is composed of x, y, and z. Lots have been drawn to determine the list of matches. Someone asked the players for the roster of the game. a says he does not compare with x, c says he does not compare with x, z, please program to find the list of the three teams.
public class Test2_1_7
{
public static void main(String args[]){
for(char i='x'; i<='z'; i++)
for(char j='x'; j<='z'; j++)
for(char k='x'; k<='z'; k++)
{
if(i!=j && i!=k && j!=k && i!='x' && k!='x' && k!='z')
System.out.println("a-"+i+",b-"+j+",c-"+k);
}
}
}