算法训练 9-7链表数据求和操作

 算法训练 9-7链表数据求和操作  
时间限制:1.0s   内存限制:512.0MB
    
  读入10个复数,建立对应链表,然后求所有复数的和。
样例输入
1 2
1 3
4 5
2 3
3 1
2 1
4 2
2 2
3 3
1 1
样例输出
23+23i
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        int n=0;int m=0;
        for(int i=0;i<10;i++){
            n+=sc.nextInt();
            m+=sc.nextInt();
        }
        System.out.println(n+"+"+m+"i");
        
    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5345798.html