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

边栏推荐
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- Current situation, analysis and prediction of information and innovation industry
- JS download files through URL links
- 3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)
- 金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
- Raft 协议
- [combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
- 解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- 关于回溯问题中的排列问题的思考(LeetCode46题与47题)
- Uniapp tips - set background music
猜你喜欢

Use and design of Muduo buffer class
[email protected])|制备路线"/>叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线

QT learning 21 standard dialog box in QT (Part 2)

FPGA test method takes mentor tool as an example

Use vscode to view hex or UTF-8 codes

Qt学习24 布局管理器(三)

Interface for querying IP home

消息订阅与发布

Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material

QT learning 24 layout manager (III)
随机推荐
Spring cup eight school league
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
Rasp implementation of PHP
Selenium browser (1)
Using registered classes to realize specific type matching function template
QT learning 23 layout manager (II)
simpleParallax. JS (create poor visual effects for website pictures)
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Back to top implementation
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
JVM class loading
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
Programmable logic device software testing
JS general form submission 1-onsubmit
如何使用lxml判断网站公告是否更新
Qt学习23 布局管理器(二)
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
Analysis of the characteristics of page owner
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
page owner特性浅析