首頁  >  文章  >  系統教程  >  AP系列之和

AP系列之和

PHPz
PHPz轉載
2024-03-13 09:43:10544瀏覽

A series with same common difference is known as arithmetic series. The first term of series is 'a' and common difference is d. The series looks like a, a d, a 2d, a 3d, . series looks like a, a d, a 2d, a 3d, . . . of series.具有相同共同差異的系列被稱為算術系列。系列的第一個術語是“ a ”,共同的區別是d。系列看起來像a d,a 2d,a 3d...找出系列的總和。

<strong>Input :</strong> a = 1
        d = 2
        n = 4
<strong>Output :</strong> 16
+ 3 + 5 + 7 = 16

<strong>Input :</strong> a = 2.5
        d = 1.5
        n = 20
<strong>Output :</strong> 335

Input:
# The first line consists of an integer T i.e number of test cases. The first line and only line of each test case consists of three integers a,d,n.

輸入:
第一行由整數T即測試用例數組成。每個測試案例的第一行和第一行由三個整數a,d,n組成。

Output:
# Print the sum of the series. With two decimal places.

輸出:
列印系列的總和。有兩位數小數。

Constraints:

1 1

約束:
1 1
例:

Input:
1 2 4
2.5 1.5 20

<strong>Output:</strong>
16.00
335.00

其實,就是一個等差數列的求和問題,不過要注意的是輸出是兩位小數。

下面是我的程式碼實作:

#include 
#include 

int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n float a scanf printf return>
<p>然後竟然出現了錯誤?一起來看一下:</p>
<p><img src="https://img.php.cn/upload/article/000/000/164/171029420168387.png" alt="AP系列之和">我試了幾次的double類型,也都是這個錯誤。不是很理解怎麼做?這個題目的考察點在哪裡哦? </p></n>

以上是AP系列之和的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:linuxprobe.com。如有侵權,請聯絡admin@php.cn刪除

相關文章

看更多