当前位置:网站首页>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

Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence _ Bili, Bili _bilibili



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

Mathematical knowledge points column of higher vocational college entrance examination : The general term formula of arithmetic sequence _ Bili, Bili _bilibili

Electronics Association Youth software programming level test C Language over the years

Electronics Association Youth software programming level test C Language over the years _dllglvzhenfeng The blog of -CSDN Blog

Electronics Association C Language Real and simulated questions

Electronics Association C Language Real and simulated questions _dllglvzhenfeng The blog of -CSDN Blog




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 5 、 Judge whether it can be 3 ,5 ,7 to be divisible by _dllglvzhenfeng The blog of -CSDN Blog

Electronics Association C Language 1 level 6 、 Cycling and walking

Electronics Association C Language 1 level 6 、 Cycling and walking _dllglvzhenfeng The blog of -CSDN Blog

Electronics Association C Language 1 level 7 、 Draw a rectangular

Electronics Association C Language 1 level 7 、 Draw a rectangular _dllglvzhenfeng The blog of -CSDN Blog

Electronics Association C Language 1 level 18 、 Calculate postage

Electronics Association C Language 1 level 18 、 Calculate postage _dllglvzhenfeng The blog of -CSDN Blog _csp test questions

Electronics Association C Language 1 level 19 、 Find the sum and mean of integers

Electronics Association C Language 1 level 19 、 Find the sum and mean of integers _dllglvzhenfeng The blog of -CSDN Blog _ Electronic Society c Language level

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 21 、 The problem of logical judgment Enter three numbers a,b,c, The largest output _dllglvzhenfeng The blog of -CSDN Blog

Electronics Association C Language 1 level 23 、 Judge the average leap year

Electronics Association C Language 1 level 23 、 Judge the average leap year _dllglvzhenfeng The blog of -CSDN Blog

 

原网站

版权声明
本文为[dllglvzhenfeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206262240200723.html