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

边栏推荐
- Qt学习17 对话框及其类型
- page owner特性浅析
- [ACNOI2022]猜数
- [acnoi2022] guess numbers
- How to bold text in AI
- Failure of vector insertion element iterator in STL
- 金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- Dynamic programming 01 knapsack and complete knapsack
- jvm-类加载
猜你喜欢

Print. JS -- web page file printing

Qt学习20 Qt 中的标准对话框(中)

Dlopen() implements dynamic loading of third-party libraries

jvm-运行时数据区

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

Generate directories from web content

Qt学习22 布局管理器(一)

Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides

QT learning 19 standard dialog box in QT (top)

JS input number and standard digit number are compared. The problem of adding 0 to 0
随机推荐
Qt学习24 布局管理器(三)
RocksDB LRUCache
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
How to promote the progress of project collaboration | community essay solicitation
Go: send the get request and parse the return JSON (go1.16.4)
Qt学习20 Qt 中的标准对话框(中)
Qt学习23 布局管理器(二)
Go 1.16.4: manage third-party libraries with Mod
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
[acnoi2022] guess numbers
QT learning 17 dialog box and its types
Record 405 questions about bank callback post request
Simulated access
[ACNOI2022]猜数
jvm-类加载
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
Summary of common error reporting problems and positioning methods of thrift
Why don't I have a rookie medal
Redis: commandes d'action pour les données de type chaîne
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