当前位置:网站首页>Exercise 6-2 using functions to sum special A-string sequences
Exercise 6-2 using functions to sum special A-string sequences
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
exercises 6-2 Using functions to find special a A string of numbers and (20 branch )
Given that neither is more than 9 The positive integer a and n, Ask to write a function to find a+aa+aaa++⋯+aa⋯a(n individual a) The sum of the .
Function interface definition :
int fn( int a, int n );
int SumA( int a, int n );
The function fn What has to be returned is n individual a The numbers that make up ;SumA Return the requested and .
Sample referee test procedure :
#include <stdio.h>
int fn( int a, int n );
int SumA( int a, int n );
int main()
{
int a, n;
scanf("%d %d", &a, &n);
printf("fn(%d, %d) = %d\n", a, n, fn(a,n));
printf("s = %d\n", SumA(a,n));
return 0;
}
/* Your code will be embedded here */
sample input :
2 3
sample output :
fn(2, 3) = 222
s = 246int fn( int a, int n ){
int i,r=a;
for(i=0;i<n-1;i++){
a=(a*10)+r;
}
return a;
}
int SumA( int a, int n ){
int i,sum=0;
for(i=1;i<=n;i++){
sum+=fn(a,i);
}
return sum;
}

边栏推荐
- FPGA测试方法以Mentor工具为例
- Comprehensive case of MySQL data addition, deletion, modification and query
- Message subscription and publishing
- Go: send the get request and parse the return JSON (go1.16.4)
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
- JS continues to explore...
- Invalid Z-index problem
- JS download files through URL links
- Golang — template
猜你喜欢

QT learning 19 standard dialog box in QT (top)

jvm-类加载

Qt学习17 对话框及其类型

如何使用lxml判断网站公告是否更新
![[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes](/img/f3/a219fe8e7438b8974d2226b4c3d4a4.png)
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes

Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue

Go language web development series 30: gin: grouping by version for routing

Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)

Interface for querying IP home

解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
随机推荐
Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
Qt学习24 布局管理器(三)
Common network state detection and analysis tools
Reflection -- basic usage
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
Article content typesetting and code highlighting
Current situation, analysis and prediction of information and innovation industry
Multi person collaborative data annotation based on Baidu brain easydata from scratch
Analysis of the characteristics of page owner
Comprehensive case of MySQL data addition, deletion, modification and query
Global event bus
The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Raft 协议
RocksDB LRUCache
Selenium browser (1)
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
JS input number and standard digit number are compared. The problem of adding 0 to 0
JVM family - overview, program counter day1-1
项目协作的进度如何推进| 社区征文