展开全部
||
public class Test{
public static void main(String[] args) {
BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
StringBuffer rs = new StringBuffer("");
int r = 0;
System.out.println("要输入e69da5e6ba9062616964757a686964616f31333332393365几行?");
try {
int count = Integer.valueOf(s.readLine());
System.out.println("请输入数字(" + count + "行)");
for (int index = 0; index
String temp = s.readLine();
String[] ns = temp.split(" ");
if (index == 0 || index == count - 1) {
for (int i = 0; i
if (i == ns.length - 1 && index == count - 1) {
rs.append(ns[i] + " = ");
r += Integer.valueOf(ns[i]);
} else {
rs.append(ns[i] + " + ");
r += Integer.valueOf(ns[i]);
}
}
} else {
rs.append(ns[0] + " + " + ns[ns.length - 1] + " + ");
r += Integer.valueOf(ns[0])
+ Integer.valueOf(ns[ns.length - 1]);
}
}
} catch (Exception e) {
// TODO: handle exception
}
System.out.println("结果: ");
System.out.println(rs.toString() + r);
}
}