C语言趣味程序百例精解之java实现(48)新娘和新郎
程序:
public class Test48{
public static void main(String args[]){
for(int x=1;x<=3;x++)
for(int y=1;y<=3;y++)
for(int z=1;z<=3;z++)
if(x!=1&&x!=3&&z!=3&&x!=y&&y!=z&&z!=x){
System.out.printf("X will marry to %c.\n",'A'+x-1);
System.out.printf("Y will marry to %c.\n",'A'+y-1);
System.out.printf("Z will marry to %c.\n",'A'+z-1);
}
}
}
C:\bat>java Test48
X will marry to B.
Y will marry to C.
Z will marry to A. |