标签:for public stat int opera nbsp system 奇数 ++
public class OperationTest{
public static void main(String[] args){
for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
System.out.println(i+"*"+j+"="+(i*j));
}
System.out.println();
}
}
}
//求1--100之间所有奇数的和?
public class OperationTest{
public static void main(String[] args){
int sum=0;
for(int i=1;i<=100;i++){
if(i%2!=0){
sum+=i;
}
}
System.out.println(sum);
//方法二:
int sum=0;
for(int i=1;i<=99;i+=2){
sum+=i;
}
System.out.println(sum);
}
}
标签:for public stat int opera nbsp system 奇数 ++
原文地址:http://www.cnblogs.com/yyh8/p/6655224.html