Java经典编程题50道之四十四】的更多相关文章

求0~7所能组成的奇数个数.分析:组成1位数是4个,组成2位数是7*4个,组成3位数是7*8*4个,组成4位数是7*8*8*4个…… public class Example44 {    public static void main(String[] args) {        f();    } public static void f() {        int sum = 4;        int j;        System.out.println("组成1位数是 &quo…
编程实现两个字符串的连接. public class Example46 {    public static void main(String[] args) {        addString("hello"," world!");    }    public static void addString(String s1,String s2){        String s3=s1+s2;        System.out.println("…
将几个字符串排序(按英文字母的顺序). public class Example40 {    public static void main(String[] args) {        String[] s={"math","english","java","java web","rose"};        stringSort(s);    } public static void stringS…
计算某字符串中子串出现的次数. public class Example49 {    public static void main(String[] args) {        String s1 = "adcdcjncfb";        String s2 = "";        count(s1, s2);    } public static void count(String str1, String str2) {        int cou…
某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下: 每位数字都加上5,然后用和除以10的余数代替该数字, 再将第一位和第四位交换,第二位和第三位交换. public class Example48 {    public static void main(String[] args) {        f(2345);    } public static void f(int num) {        int[] c = new int[4];      …
判断一个整数能被几个9整除. public class Example45 {    public static void main(String[] args) {        f(729);    } public static void f(int n) {        int tmp = n;        int count = 0;        for (int i = 0; tmp % 9 == 0;) {            tmp = tmp / 9;         …
809*??=800*??+9*??+1,其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数.求??代表的两位数,以及809*??后的结果. public class Example42 {    public static void main(String[] args) {        f();    } public static void f() {        int a = 809, b, i;        for (i = 10; i < 13; i++)…
输入3个数a,b,c,按大小顺序输出. public class Example34 {    public static void main(String[] args) {        sort(5, 20, 15);    } public static void sort(int a, int b, int c) {        if (a < b) {            int t = a;            a = b;            b = t;        …
输入某年某月某日,判断这一天是这一年的第几天? public class Example14 {    public static void main(String[] args) {        year(2017, 1, 1);    } public static void year(int year, int month, int day) {        int d = 0;        int days = 0;        if (year < 0 || month <…
有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),计算出平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件 "stud"中. public class Example50 {    public static void main(String[] args) {        stud();    } public static void stud() {        Scanner ss = new Scanner(System.in); …