当前位置:网站首页>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
边栏推荐
- [fundamentals of image processing] GUI image histogram equalization system based on MATLAB [including Matlab source code 1924]
- Introduction to operator
- VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)
- Some ways out for older programmers
- LabVIEW Arduino tcp/ip remote smart home system (project part-5)
- FPGA -vga display
- Yolov6: un cadre de détection de cibles rapide et précis est Open Source
- 开放世界机甲游戏-Phantom Galaxies
- Bs-gx-016 implementation of textbook management system based on SSM
- Installation avec homebrew dans un environnement Mac OS [email protected]
猜你喜欢

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,

Product design in the extreme Internet Era

UnityEditor编辑器扩展-表格功能

Parsing complex JSON in fluent
![leetcode:710. Random numbers in the blacklist [mapping thinking]](/img/ec/a3faeae6636bc3d0d9536962fdd9af.png)
leetcode:710. Random numbers in the blacklist [mapping thinking]

Data governance does everything

Vulnhub's dc9

數據清洗工具flashtext,效率直接提昇了幾十倍數

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

MATLAB and MySQL database connection and data exchange (based on ODBC)
随机推荐
Product design in the extreme Internet Era
Centos7 compiling and installing redis
不同的子序列问题I
【LeetCode】1984. Minimum difference between highest and lowest of K scores
leetcode:710. Random numbers in the blacklist [mapping thinking]
leetcode:6107. 不同骰子序列的数目【dp六个状态 + dfs记忆化】
Introduction de l'opérateur
不花一分钱做个在线的gif合成服务
尚硅谷DolphinScheduler视频教程发布
leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]
开放世界机甲游戏-Phantom Galaxies
Fastadmin Aurora push send message registration_ Multiple IDs are invalid after being separated by commas
Unity3D插件 AnyPortrait 2D骨骼动画制作
leetcode:152. 乘积最大子数组【考虑两个维度的dp】
Installation avec homebrew dans un environnement Mac OS [email protected]
random_ normal_ Initializer uses
VB. Net class library (Advanced - 2 overload)
电子协会 C语言 1级 31 、 计算线段长度
树莓派初步使用
Pass note 【 dynamic planning 】