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

边栏推荐
- Vite project commissioning
- Richview trvstyle liststyle list style (bullet number)
- Multi person collaborative data annotation based on Baidu brain easydata from scratch
- QT learning 25 layout manager (4)
- Collection of mobile adaptation related articles
- 全局事件总线
- Analysis of the characteristics of page owner
- Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
- 信创产业现状、分析与预测
- [développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
猜你喜欢

Richview trvstyle liststyle list style (bullet number)

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

Installation impression notes

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
[email "/>Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email

Go: send the get request and parse the return JSON (go1.16.4)

解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
![[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered](/img/06/b71b505c7072d540955fda6da1dc1b.jpg)
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ

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
随机推荐
[technology development-24]: characteristics of existing IOT communication technology
3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
TS code automatically generates JS
全局事件总线
Duet date picker (time plug-in that can manually enter the date)
Message subscription and publishing
Collection of mobile adaptation related articles
Generate directories from web content
Back to top implementation
Dlopen() implements dynamic loading of third-party libraries
Common mixins
GoLand 2021.1: rename the go project
如何使用lxml判断网站公告是否更新
信创产业现状、分析与预测
QT learning 23 layout manager (II)
JVM class loading
Go 1.16.4: purpose of go mod tidy
Current situation, analysis and prediction of information and innovation industry
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(