public class WhileDemo {
/*求1-10的和*/
public static void main (String[] args ){
int x = 1 ;
int sum = 0;
while(x<11){
sum=sum+x;
x++;
}
System.out.println("sum="+sum);
}
}
时间: 2025-01-25 09:09:50
public class WhileDemo {
/*求1-10的和*/
public static void main (String[] args ){
int x = 1 ;
int sum = 0;
while(x<11){
sum=sum+x;
x++;
}
System.out.println("sum="+sum);
}
}