欢迎大家指出不足,有红包!!!
- 1.正在学习英语的童鞋们,涨姿势的时候到了...
public static void main(String[] args) {
// TODO Auto-generated method stub
int i =(int)(Math.ceil((122-97)*Math.random()))+97;
char c = (char)i;
System.out.print(c+"是:");
switch(c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println("元音字母");
break;
case 'y':
case 'w':
System.out.println("半元音字母");
break;
default :
System.out.println("辅音字母");
}
//被3整除的数的和
int j = 1;
int sum1 = 0;
do {
if (j%3==0) {
sum1 += j;
}
j++;
}while (j <= 100);
System.out.println(sum1);
//1-100的偶数和与奇数和
int sum2=0,sum3=0,sum4=0,sum5=0;
for (int m =1;m < 101; m++) {
if (m%2==0) {
sum2 += m;
}else
sum3 += m;
}
System.out.println("1-100的偶数和:"+sum2);
System.out.println("1-100的奇数和:"+sum3);
int p = 0;
do {
p++;
if (p%2==0)
sum4 += p;
else
sum5 += p;
}while (p<100);
System.out.println("1-100的偶数和:"+sum4);
System.out.println("1-100的奇数和:"+sum5);
- 3.随机1-100的数,随机到88可能是第几次?
int total = 0;
while (true) {
total ++;
int i = (int)Math.round(Math.random()*100);
if (i == 88)
break;
}
System.out.println("循环了"+total+"次");
- 4.输出矩形菱形平行四边形九九乘法表,谢某人的指导
for (int i= 0 ;i < 5; i ++) {
for (int j = 0; j < 5; j ++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~");
for (int i = 1; i <= 5; i ++) {
for (int j = 5-1-i; j >= 0; j --) {
System.out.print(" ");
}
for (int k = 1; k <= 2*i-1; k ++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 4; i >= 1; i--) {
for (int j = 0; j <= 5-1-i; j ++) {
System.out.print(" ");
}
for (int k = 2*i-1; k >= 1; k --) {
System.out.print("*");
}
System.out.println();
}
System.out.println("---------------------");
for (int i = 0; i < 5; i ++) {
for (int j = 5-i; j > 0;j --) {
System.out.print(" ");
}
for (int k = 0; k < 5; k ++) {
System.out.print("*");
}
System.out.println();
}
System.out.println("--------------------");
//有鸡翁一,值钱伍;鸡母一,值钱三;鸡鶵三,值钱一。凡百钱买鸡百只,问鸡翁、母、鶵各几何?
//有鸡翁一,值钱伍;鸡母一,值钱三;鸡鶵三,值钱一。凡百钱买鸡百只,问鸡翁、母、鶵各几何?
final int gongJi = 15;
final int muJi = 9;
final int xiaoJi = 1;
int sum = 0, sum1 = 0;
for (int m = 0; m < 20; m ++) {
for (int w = 0; w < 33; w ++) {
for (int c = 0; c < 301; c ++) {
sum = (m * gongJi + w * muJi + c * xiaoJi);
sum1 = (m + w + c);
if ((sum == 300) && (sum1 == 100))
System.out.println("gongJi有" + m + "muJi有" + w + "xiaoJi有" + c);
}
}
}
System.out.println("--------------------");
for (int i = 0; i <= 9; i ++) {
for (int j = 1; j < i+1; j ++) {
System.out.print(i+"*"+j+"="+i*j+"\t");
}
System.out.println();
}