package a; public class QiuHe { private int m; private int n; public int getM() { return m; } public void setM(int m) { this.m = m; } public int getN() { return n; } public void setN(int n) { this.n = n; } public void qiuhe() { int sum=0; String p=String.valueOf(m); for (int i = 0; i < n; i++) { sum=sum+new Integer(p); p=p+String.valueOf(m); } System.out.println("求和结果为: "+sum); } public static void main(String[] args) { QiuHe q=new QiuHe(); q.setM(3); q.setN(4); q.qiuhe(); } }
转载于:https://www.cnblogs.com/wenwen123/p/5534050.html