本文主要是介绍洛谷 Java P2089_烤鸡,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
package 新手村.BOSS入门练习;import java.util.Scanner;public class P2089 {public static void main(String[] args){Scanner in = new Scanner(System.in);int kk = in.nextInt();//配料int a,b,c,d,e,f,g,h,i,j,count=0;for (a=1;a<=3;a++){for (b=1;b<=3;b++){for (c=1;c<=3;c++){for (d=1;d<=3;d++){for (e=1;e<=3;e++){for (f=1;f<=3;f++){for (g=1;g<=3;g++){for(h=1;h<=3;h++){for (i=1;i<=3;i++){for (j=1;j<=3;j++){if (a+b+c+d+e+f+g+h+i+j==kk){count++;}}}}}}}}}}}System.out.println(count);for (a=1;a<=3;a++){for (b=1;b<=3;b++){for (c=1;c<=3;c++){for (d=1;d<=3;d++){for (e=1;e<=3;e++){for (f=1;f<=3;f++){for (g=1;g<=3;g++){for(h=1;h<=3;h++){for (i=1;i<=3;i++){for (j=1;j<=3;j++){if (a+b+c+d+e+f+g+h+i+j==kk){System.out.println((int)a+" "+(int)b+" "+(int)c+" "+(int)d+" "+(int)e+" "+(int)f+" "+(int)g+" "+(int)h+" "+(int)i+" "+(int)j);}}}}}}}}}}}}
}
这篇关于洛谷 Java P2089_烤鸡的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!