当前位置:网站首页>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
边栏推荐
- Wechat applet is authorized to log in wx getUserProfile
- Word chess based on heuristic search
- C语言:简单计算器多次使用代码实现
- 【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
- npm 命令提示Error: EACCES: permission denied
- Centos7编译安装Redis
- NPM command prompt error: eacces: permission denied
- Weaving dream collection plug-ins are recommended to be free collection plug-ins
- Installation avec homebrew dans un environnement Mac OS [email protected]
- Bs-gx-016 implementation of textbook management system based on SSM
猜你喜欢

Unity: 脚本缺失 “The referenced script (Unknown) on this Behaviour is missing!“
![[machine learning] - Introduction to vernacular and explanation of terms](/img/4c/e18fe52a71444c2ca08167ead9f28f.jpg)
[machine learning] - Introduction to vernacular and explanation of terms

Product design in the extreme Internet Era

CVPR 2022 | 美团技术团队精选论文解读

leetcode:710. 黑名单中的随机数【映射思维】

BS-GX-016基于SSM实现教材管理系统
![[cloud native topic -51]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware redis microservice deployment process](/img/42/c2a25bb7a9fdad8fe0a048e9af44ca.jpg)
[cloud native topic -51]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware redis microservice deployment process

Yolov6: the fast and accurate target detection framework is open source

Configuring assimp Library in QT environment (MinGW compiler)

【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
随机推荐
The network connection is disconnected. Please refresh and try again
在哪个平台买股票开户最安全?求分享
打新债注册开户有没有什么风险?安全吗?
leetcode:710. 黑名单中的随机数【映射思维】
Bs-gx-016 implementation of textbook management system based on SSM
[mixed programming JNI] Part 7: JNI command lines
CVPR 2022 | 美团技术团队精选论文解读
Centos7编译安装Redis
【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
Do an online GIF synthesis service at no cost
Unity method for setting material and shader
【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
leetcode:6107. 不同骰子序列的数目【dp六个状态 + dfs记忆化】
在Flutter中解析复杂的JSON
简析攻防演练中蓝队的自查内容
C language: a simple calculator is implemented by using code many times
Microservices, an important part of cloud native architecture
开放世界机甲游戏-Phantom Galaxies
Reading graph augmentations to learn graph representations (lg2ar)
FPGA -VGA显示