Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
while (true)
{
int m = cin.nextInt();
int n = cin.nextInt();
if (m <= 0 || n <= 0)
break;
if (m > n)
{
m += n;
n = m -n;
m -= n;
}
int sum = 0;
for (int i = m; i < n+1; i ++)
{
System.out.print(i + " ");
sum += i;
}
System.out.print("Sum="+ sum + "\n");
}
}
}