import java.util.Scanner;
class ForTest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入要求和的值:");
int num = sc.nextInt();
int count1 = sumFunction(num);
System.out.println(count1);
}
static int sumFunction(int num) {
System.out.println("*******************");
int count = 0;
int m;
for(m = 1; m <= num; m++) {
count = count + m;
}
return count;
}
}
大神评点一下! |
|