Java 在级数中求n和 /* *要更改此模板,请选择工具|模板 *然后在编辑器中打开模板。 */ 一揽子练习_4.pkg25; /** * *@作者14111985 */ 公共课练习应用程序{ /** *@param指定命令行参数 */ 公共静态void main(字符串[]args){ int-total=0; int-sumofttotal=0; int n=0; 对于(int i=1;i

Java 在级数中求n和 /* *要更改此模板,请选择工具|模板 *然后在编辑器中打开模板。 */ 一揽子练习_4.pkg25; /** * *@作者14111985 */ 公共课练习应用程序{ /** *@param指定命令行参数 */ 公共静态void main(字符串[]args){ int-total=0; int-sumofttotal=0; int n=0; 对于(int i=1;i,java,Java,如果我是正确的,那么您的系列将出现在Ap中。 对于Ap中的系列,使用nnumber=n*(a+l)/2的公式和; 这里第一项是a,最后一项是l /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package exercise_4.pkg25; /** * * @author 14111985 */ public class Exercis

如果我是正确的,那么您的系列将出现在
Ap
中。 对于
Ap
中的系列,使用n
number=n*(a+l)/2的公式和;
这里第一项是a,最后一项是l

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercise_4.pkg25;

/**
 *
 * @author 14111985
 */
public class Exercise_425App {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        int total = 0;
        int sumOfTotal = 0;
        int n = 0;


        for (int i = 1; i <= 5; i++) {

            total += i;
            sumOfTotal += total;
        }
        System.out.println(sumOfTotal);
    }
}
publicstaticvoidmain(字符串[]args){
int-total=0;
int-sumofttotal=0;
int n=0;

对于(int i=1;我不应该是输入/for循环上的条件?你的意思是,给定一个和值,“n”的值是多少?不应该是输入。问题是打印和打印n。老实说,我看不出我的问题有什么不好。不知道为什么我得了负10分!@user109649我猜是因为你似乎复制/粘贴了一个宏作业作业,没有明确说明你想做什么,也没有显示出你自己解决问题的任何努力。如果你读过这篇文章,我在这里提到的第一学期是a,最后一学期是l。所以你可以如下声明。a int a=1,int l=5;int sumOfTotal=0;int n=0;谢谢natwar
public static void main(String[] args) {

        int total = 0;
        int sumOfTotal = 0;
        int n = 0;


        for (int i = 1; i <= 5; i++) {

            total += i;
            sumOfTotal += total;
        }

           n=(sumOfTotal*2)/(a+l);
           System.out.println("value of n is"+ n);
        System.out.println(sumOfTotal);
    }