}
for(int j=0;j 9. 编写函数,将给定的字符串的大写字母转变成小写字母; 其它字符不变。主函数输入一个字符串,调用该函数对其进行转换,分别输出原串和转换之后的串。 package moreEasy; import java.util.Scanner; public class The9th { static String str=\ public static void main(String[] args) { String str=\ Scanner cin=new Scanner(System.in); str=cin.nextLine(); zhuanHuan(str); } public static void zhuanHuan(String str1){ str=str1; str=str.toLowerCase(); System.out.println(str); } } 10. 编写一个函数,将字符数组a中的全部字符复制到字符数组b中. 不要使用strcpy函数. 主函数输入任意一个字符串,调该函数,复制出另一个字符串。将两个串输出。 package moreEasy; import java.util.Scanner; public class The10th { public static void main(String[] args) { Scanner cin=new Scanner(System.in); String str=cin.nextLine(); char[] aa=new char[str.length()]; char[] bb=new char[str.length()]; for(int i=0;i copy(aa,bb); for(int i=0;i 409--17 System.out.println(\ for(int i=0;i public static void copy(char[] a,char[] b){ for(int i=0;i 11. 判断一个N*N的矩阵是否为对称矩阵. 将原矩阵输出,判断结果输出. package moreEasy; import java.util.Scanner; public class The11th { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int n=cin.nextInt(); int count=0; int[][] duiCheng=new int[n][n]; for(int i=0;i for(int j=0;j for(int i=0;i for(int j=0;j System.out.print(duiCheng[i][j]+\ else System.out.print(duiCheng[i][j]+\ } for(int i=0;i for(int j=0;j if(count==n*n) System.out.println(\对称矩阵\ else System.out.println(\非对称矩阵\ } 409--18 } 12. 给出年、月、日, 计算该日是该年的第几天? package moreEasy; import java.util.Scanner; public class The12th { public static void main(String[] args) { int n=0; Scanner cin=new Scanner(System.in); int y=cin.nextInt(); System.out.println(\年\ int m=cin.nextInt(); System.out.println(\月\ int d=cin.nextInt(); System.out.println(\日\ if(y%4==0&&y0!=0||y@0==0){ switch(m){ case 1: n=d; break; case 2: n=d+31; break; case 3: n=d+31+29; break; case 4: n=d+31+29+31; break; case 5: n=d+31+29+31+30; break; case 6: n=d+31+29+31+30+31; break; case 7: n=d+31+29+31+30+31+30; break; case 8: n=d+31+29+31+30+31+30+31; break; case 9: n=d+31+29+31+30+31+30+31+31; break; case 10: n=d+31+29+31+30+31+30+31+31+30; break; 409--19 case 11: n=d+31+29+31+30+31+30+31+31+30+31; break; case 12: n=d+31+29+31+30+31+30+31+31+30+31+30; break; } switch(m){ case 1: n=d; break; case 2: n=d+31; break; case 3: n=d+31+28; break; case 4: n=d+31+28+31; break; case 5: n=d+31+28+31+30; break; case 6: n=d+31+28+31+30+31; break; case 7: n=d+31+28+31+30+31+30; break; case 8: n=d+31+28+31+30+31+30+31; break; case 9: n=d+31+28+31+30+31+30+31+31; break; case 10: n=d+31+28+31+30+31+30+31+31+30; break; case 11: n=d+31+28+31+30+31+30+31+31+30+31; break; case 12: n=d+31+28+31+30+31+30+31+31+30+31+30; break; 409--20 } else{
相关推荐: