Java

CHENLV 发表于 22天前 · 关联问题 计算数的和

import java.util.Scanner; public class Main{

public static void main(String[] args){ Scanner sc = new Scanner(System.in); int result = 0; while(true){ int temp = sc.nextInt(); if(temp>0){result += temp;} if(temp == 0){break;} } System.out.println(result); }

}