标签:java
水题。。。
import java.util.Scanner; public class Main { static int m1, m2; static int r1, r2, r3; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { m1 = m2 = r1 = r2 = r3 = 0; m1 = sc.nextInt(); m2 = sc.nextInt(); String order = sc.next(); for (int i = 0; i < order.length(); i++) { calculate(order.charAt(i)); } System.out.println(m1 + "," + m2); } } public static void calculate(char ch) { switch (ch) { case 'A': r1 = m1; break; case 'B': r2 = m2; break; case 'C': m1 = r3; break; case 'D': m2 = r3; break; case 'E': r3 = r1 + r2; break; case 'F': r3 = r1 - r2; break; default: break; } } }
100 288 ABECED 876356 321456 ABECAEDBECAF
388,388 2717080,1519268
标签:java
原文地址:http://blog.csdn.net/hncu1306602liuqiang/article/details/46470315