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

边栏推荐
- C language standard IO function sorting
- JS first summary
- Golang — template
- Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
- Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
- QT learning 20 standard dialog box in QT (middle)
- Qt学习25 布局管理器(四)
- [Jilin University] information sharing of postgraduate entrance examination and re examination
- Go language web development series 30: gin: grouping by version for routing
- Analysis of the characteristics of page owner
猜你喜欢

Qt学习18 登录对话框实例分析

QT learning 17 dialog box and its types

使用vscode查看Hex或UTF-8编码

Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS

3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)

关于回溯问题中的排列问题的思考(LeetCode46题与47题)

Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)

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

Richview trvstyle liststyle list style (bullet number)

“又土又穷”的草根高校,凭什么被称为“东北小清华”?
随机推荐
Qt学习22 布局管理器(一)
Analysis of the characteristics of page owner
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
Rasp implementation of PHP
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
Go: send the get request and parse the return JSON (go1.16.4)
全局事件总线
How to bold text in AI
Implementation of Muduo asynchronous logging
Use vscode to view hex or UTF-8 codes
Generate directories from web content
JVM object lifecycle
Raft 协议
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Qt学习23 布局管理器(二)
Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
GoLand 2021.1: rename the go project
Vite project commissioning
JS input number and standard digit number are compared. The problem of adding 0 to 0
1px problem of mobile terminal