当前位置:网站首页>电子协会 C语言 1级 30 、 等差数列末项计算
电子协会 C语言 1级 30 、 等差数列末项计算
2022-06-26 22:40:00 【dllglvzhenfeng】
电子协会 C语言 1级 30 、 等差数列末项计算
高职高考数学知识点数列:等差数列的通项公式
高职高考数学知识点数列:等差数列的通项公式_哔哩哔哩_bilibili
C++ 代码:方法一
/*
电子协会 C语言 1级 30 、 等差数列末项计算
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
给出一个等差数列的前两项 a1,a2,求第 n 项是多少。
输入
一行,包含三个整数 a1,a2,n。-100 <= a1,a2 <= 100,0 < n <= 1000。
输出
一个整数,即第 n 项的值。
样例输入:1 4 100
样例输出:298
3 6 9 12 15
高职高考数学知识点数列:等差数列的通项公式
https://www.bilibili.com/video/BV13U4y1p7ec
*/
#include<iostream>
using namespace std;
int main()
{
int a1,a2,an,n;
cin>>a1>>a2>>n;
//公差d=a2-a1=a3-a2=a4-a3=an-an-1
an=a1+(n-1)*(a2-a1);//等差数列通项公式
cout<<an;
return 0;
} C++代码:方法二
/*
电子协会 C语言 1级 30 、 等差数列末项计算 方法二
http://noi.openjudge.cn/math/7654/
http://noi.openjudge.cn/ch0103/18/
1047:判断能否被3,5,7整除---好
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代码:
a1,a2,n=map(int,input().split())
d=a2-a1
an=a1+(n-1)*d
print(an)电子学会青少年编程等级考试
https://blog.csdn.net/dllglvzhenfeng/category_11735875.html
电子协会 C语言 1级 30 、 等差数列末项计算
高职高考数学知识点数列:等差数列的通项公式
高职高考数学知识点数列:等差数列的通项公式_哔哩哔哩_bilibili
电子协会 青少年软件编程等级考试 C语言历年真题
电子协会 青少年软件编程等级考试 C语言历年真题_dllglvzhenfeng的博客-CSDN博客
电子协会C语言 真题与模拟题
电子协会C语言 真题与模拟题_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 5 、判断能否被 3 ,5 ,7 整除
电子协会 C语言 1级 5 、判断能否被 3 ,5 ,7 整除_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 6 、骑车与走路
电子协会 C语言 1级 6 、骑车与走路_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 7 、画矩形
电子协会 C语言 1级 7 、画矩形_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 18 、计算邮资
电子协会 C语言 1级 18 、计算邮资_dllglvzhenfeng的博客-CSDN博客_csp试题
电子协会 C语言 1级 19 、求整数的和与均值
电子协会 C语言 1级 19 、求整数的和与均值_dllglvzhenfeng的博客-CSDN博客_电子学会c语言一级
电子协会 C语言 1级 21 、逻辑判断问题 输入三个数 a,b,c,输出最大者
电子协会 C语言 1级 21 、逻辑判断问题 输入三个数 a,b,c,输出最大者_dllglvzhenfeng的博客-CSDN博客
电子协会 C语言 1级 23 、判断平闰年
电子协会 C语言 1级 23 、判断平闰年_dllglvzhenfeng的博客-CSDN博客
边栏推荐
- Which securities company is the most convenient, safe and reliable for opening an account
- VB. Net class library (Advanced - 2 overload)
- 【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
- LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
- Centos7编译安装Redis
- 數據清洗工具flashtext,效率直接提昇了幾十倍數
- Introduction to operator
- Leetcode - the best time to buy or sell stocks
- 简析攻防演练中蓝队的自查内容
- 【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
猜你喜欢

The sharp sword of API management -- eolink

在线协作文档综合评测 :Notion、FlowUs、Wolai、飞书、语雀、微软 Office、谷歌文档、金山文档、腾讯文档、石墨文档、Dropbox Paper、坚果云文档、百度网盘在线文档

Parsing complex JSON in fluent
![leetcode:141. Circular linked list [hash table + speed pointer]](/img/19/f918f2cff9f831d4bbc411fe1b9776.png)
leetcode:141. Circular linked list [hash table + speed pointer]

大龄程序员的一些出路

Application and Optimization Practice of 100 million level monthly live national karaoke feed service in Tencent cloud mongodb

FPGA -VGA显示

DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力

数据治理啥都干

【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
随机推荐
Bs-gx-016 implementation of textbook management system based on SSM
[bug feedback] the problem of message sending time of webim online chat system
Flashtext, a data cleaning tool, has directly increased the efficiency by dozens of times
LabVIEW Arduino tcp/ip remote smart home system (project part-5)
Unity3d plug-in anyportrait 2D bone animation
【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
C语言:简单计算器多次使用代码实现
Briefly describe the model animation function of unity
nmap参数详解
[cloud native topic -51]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware redis microservice deployment process
Data governance does everything
Leetcode - the best time to buy or sell stocks
Which platform is the safest for buying stocks and opening accounts? Ask for sharing
中金证券经理的开户链接开户买股票安全吗?有谁知道啊
Is there any risk for flush to register and open an account? Is it safe?
[mixed programming JNI] Part 6: operation of strings and arrays in native
leetcode:710. Random numbers in the blacklist [mapping thinking]
Yolov6: un cadre de détection de cibles rapide et précis est Open Source
Microservices, an important part of cloud native architecture
Detailed explanation of nmap parameters