输出
import java.util.Scanner; public class text10{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { System.out.print(i); } System.out.println(); } } }
输出金字塔※号
import java.util.Scanner; public class text11 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=1;j<=n-i;j++) System.out.print(' '); for(j=1;j<=2*i-1;j++) System.out.print('*'); System.out.println(); } } }
输出
import java.util.Scanner; public class text12 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) System.out.print(j); System.out.println(); } } }
输出
import java.util.Scanner; public class text13 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=n;i>=1;i--) { for(j=1;j<=n-i;j++) System.out.print(' '); for(j=1;j<=i;j++) System.out.print(j); System.out.println(); } } }
输出
import java.util.Scanner; public class text14 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=n-i;j>=1;j--) System.out.print(' '); for(j=1;j<=2*i-1;j++) System.out.print(i); System.out.println(); } for(i=n-1;i>=1;i--) { for(j=n-i;j>=1;j--) System.out.print(' '); for(j=1;j<=2*i-1;j++) System.out.print(i); System.out.println(); } } }
输出
import java.util.Scanner; public class text15 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i,j,n; n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=n-i;j>=1;j--) System.out.print(' '); System.out.print(i); for(j=2*i-3;j>=1;j--) System.out.print(' '); if(i!=1) System.out.print(i); System.out.println(); } for(i=n-1;i>=1;i--) { for(j=n-i;j>=1;j--) System.out.print(' '); System.out.print(i); for(j=2*i-3;j>=1;j--) System.out.print(' '); if(i!=1) System.out.print(i); System.out.println(); } } }
用一元纸币兑换一分、二分、五分的硬币,要求兑换硬币的总数为50枚,问有多少种兑换方法?每种兑换方法各种硬币分别多少枚?
public class text16 { public static void main(String[] args) { int x,y,z; for(x=0;x<=50;x++) for(y=0;y<=50;y++) for(z=0;z<=50;z++) if(x+y+z==50) System.out.println("一分="+x+"两分="+y+"五分="+z); } }
时间: 2024-10-13 02:33:32