当前位置:网站首页>Electronic Society C language level 1 30, calculation of last term of arithmetic sequence
Electronic Society C language level 1 30, calculation of last term of arithmetic sequence
2022-06-26 22:46:00 【dllglvzhenfeng】
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
OpenJudge - 7654: Calculation of the last term of the arithmetic sequence
OpenJudge - 18: Calculation of the last term of the arithmetic sequence
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
C++ Code : Method 1
/*
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
Give the first two terms of an arithmetic sequence a1,a2, Please n What is the item? .
Input
a line , Contains three integers a1,a2,n.-100 <= a1,a2 <= 100,0 < n <= 1000.
Output
An integer , That is to say n Item value .
The sample input :1 4 100
Sample output :298
3 6 9 12 15
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
https://www.bilibili.com/video/BV13U4y1p7ec
*/
#include<iostream>
using namespace std;
int main()
{
int a1,a2,an,n;
cin>>a1>>a2>>n;
// tolerance d=a2-a1=a3-a2=a4-a3=an-an-1
an=a1+(n-1)*(a2-a1);// General term formula of arithmetic sequence
cout<<an;
return 0;
} C++ Code : Method 2
/*
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence Method 2
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
1047: Judge whether it can be 3,5,7 to be divisible by --- good
https://blog.csdn.net/weixin_43877387/article/details/118456563
*/
#include<iostream>
using namespace std;
int main()
{
int a1,a2,n,d;
cin>>a1>>a2>>n;
d=a2-a1;
cout<<a1+(n-1)*d;
return 0;
}python3 Code :
a1,a2,n=map(int,input().split())
d=a2-a1
an=a1+(n-1)*d
print(an)Electronic Society junior programming grade test
https://blog.csdn.net/dllglvzhenfeng/category_11735875.html
Electronics Association C Language 1 level 30 、 Calculation of the last term of the arithmetic sequence
OpenJudge - 7654: Calculation of the last term of the arithmetic sequence
OpenJudge - 18: Calculation of the last term of the arithmetic sequence
Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence
Electronics Association Youth software programming level test C Language over the years
Electronics Association C Language Real and simulated questions
Electronics Association C Language 1 level 5 、 Judge whether it can be 3 ,5 ,7 to be divisible by
Electronics Association C Language 1 level 6 、 Cycling and walking
Electronics Association C Language 1 level 7 、 Draw a rectangular
Electronics Association C Language 1 level 18 、 Calculate postage
Electronics Association C Language 1 level 19 、 Find the sum and mean of integers
Electronics Association C Language 1 level 21 、 The problem of logical judgment Enter three numbers a,b,c, The largest output
Electronics Association C Language 1 level 23 、 Judge the average leap year
边栏推荐
- Some ways out for older programmers
- random_ normal_ Initializer uses
- vulnhub之dc8
- 主从复制系统设计
- 在线协作文档综合评测 :Notion、FlowUs、Wolai、飞书、语雀、微软 Office、谷歌文档、金山文档、腾讯文档、石墨文档、Dropbox Paper、坚果云文档、百度网盘在线文档
- [mixed programming JNI] Part 6: operation of strings and arrays in native
- Detailed explanation of nmap parameters
- Operator介绍
- Yolov6: un cadre de détection de cibles rapide et précis est Open Source
- 【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
猜你喜欢

CVPR 2022 | 美团技术团队精选论文解读
![leetcode:141. Circular linked list [hash table + speed pointer]](/img/19/f918f2cff9f831d4bbc411fe1b9776.png)
leetcode:141. Circular linked list [hash table + speed pointer]

Using C to operate SQLSERVER database through SQL statement tutorial

Leetcode (452) - detonate the balloon with the minimum number of arrows

Unity4.6版本下载

用C#通过sql语句操作Sqlserver数据库教程

VB. Net class library (Advanced - 2 overload)

Reading graph augmentations to learn graph representations (lg2ar)

LabVIEW Arduino tcp/ip remote smart home system (project part-5)

Configuring assimp Library in QT environment (MinGW compiler)
随机推荐
WP collection plug-in tutorial no thanks for WordPress collection of rules
BS-GX-016基于SSM实现教材管理系统
分享三种在Excel表格中自动求和的方法
MacOS環境下使用HomeBrew安裝[email protected]
MATLAB and MySQL database connection and data exchange (based on ODBC)
CVPR 2022 | 美团技术团队精选论文解读
Leetcode (763) -- dividing letter ranges
[bug feedback] the problem of message sending time of webim online chat system
Using C to operate SQLSERVER database through SQL statement tutorial
C语言:简单计算器多次使用代码实现
Homebrew installation in MacOS environment [email protected]
6.24 学习内容
数据治理啥都干
电子协会 C语言 1级 30 、 等差数列末项计算
Why don't I recommend going to sap training institution for training?
LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
Briefly describe the model animation function of unity
Is there any risk in opening a new bond registration account? Is it safe?
Unity4.6版本下载
Comprehensive evaluation of online collaboration documents: note, flowus, WOLAI, Feishu, YuQue, Microsoft office, Google Docs, Jinshan docs, Tencent docs, graphite docs, Dropbox paper, nutcloud docs,