3 ^ 1 = 3 3 ^ 2 = 9 3 ^ 3 = 27 总结果= 40 .. ... http://imageshack.com/a/img571/5209/lzb1.png[^]and this my code but this code give just one by one result . i need total resultfor example; for N =31^0=11^1=11^2=11^3=1total result =4 and2^0=12^1=22^2=42^3=8total result =15 and3^0=13^1=33^2=93^3=27total result =40 ..... import java.awt.image.ConvolveOp;import java.io.*;import javax.swing.JOptionPane;import java.util.Scanner;public class main { public static void main(String[] args){ double sonuc; String N=JOptionPane.showInputDialog("Enter N"); int STPN= Integer.parseInt(N); for(double Rho=1; Rho<=3;Rho++){ for(int i=0;i<=STPN;i++){ sonuc=Math.pow(Rho,i); System.out.println("Sonuc : " + sonuc); } } }} 推荐答案 我用值3运行它,得到以下结果: I run that with the value 3, and get the following results:> run TestSonuc : 1.0Sonuc : 1.0Sonuc : 1.0Sonuc : 1.0Sonuc : 1.0Sonuc : 2.0Sonuc : 4.0Sonuc : 8.0Sonuc : 1.0Sonuc : 3.0Sonuc : 9.0Sonuc : 27.0 请解释这部分是错误的以及原因。Please explain which part of this is wrong and why. for(int Rho=1; Rho<=STPN;Rho++){ int count=0; for(int i=0;i<=STPN;i++){ count=(int) (count+Math.pow(Rho, i)); System.out.print(Rho+"^"+i+" = "); System.out.println(count); } System.out.println("The Total Result Is = "+count); } 用这段代码替换你的代码只需看看Replace your code with this code it will be work just see 这篇关于我是如何在Java中解决这个问题的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 16:24