当前位置:网站首页>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
边栏推荐
- Release of dolphin scheduler video tutorial in Shangsi Valley
- 數據清洗工具flashtext,效率直接提昇了幾十倍數
- 美术向的Unity动画知识
- [mixed programming JNI] Part 9: JNI summary
- Vulnhub's DC8
- leetcode:710. Random numbers in the blacklist [mapping thinking]
- Yolov6: the fast and accurate target detection framework is open source
- Is there any risk for flush to register and open an account? Is it safe?
- 在哪家券商公司开户最方便最安全可靠
- Leetcode (452) - detonate the balloon with the minimum number of arrows
猜你喜欢
从位图到布隆过滤器,C#实现
VB. Net class library (Advanced - 2 overload)
360 mobile assistant is the first to access the app signature service system to help distribute privacy and security
Parsing complex JSON in fluent
Yolov6: the fast and accurate target detection framework is open source
Word chess based on heuristic search
Pass note 【 dynamic planning 】
开放世界机甲游戏-Phantom Galaxies
數據清洗工具flashtext,效率直接提昇了幾十倍數
【老卫搞机】090期:键盘?主机?全功能键盘主机!
随机推荐
curl: (35) LibreSSL SSL_ connect: SSL_ ERROR_ SYSCALL in connection
YOLOv6:又快又准的目标检测框架开源啦
Open world mecha games phantom Galaxy
Is this a bug? Whether the randomly filled letters can be closed
Unity3D插件 AnyPortrait 2D骨骼动画制作
[mixed programming JNI] Part 12 jnaerator
[cloud native topic -51]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware redis microservice deployment process
Weaving dream collection plug-ins are recommended to be free collection plug-ins
Centos7 compiling and installing redis
中金证券经理的开户链接开户买股票安全吗?有谁知道啊
LabVIEW Arduino tcp/ip remote smart home system (project part-5)
Module externe unity3d anyportrait 2D Skeleton Animation
DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力
用C#通过sql语句操作Sqlserver数据库教程
[Old Wei makes machines] issue 090: keyboard? host? Full function keyboard host!
从位图到布隆过滤器,C#实现
leetcode - 买卖股票的最佳时机
Using C to operate SQLSERVER database through SQL statement tutorial
What are the test case design methods?
LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)