当前位置:网站首页>Exercise 6-2 using functions to sum a special series of a numbers (20 points)
Exercise 6-2 using functions to sum a special series of a numbers (20 points)
2022-06-11 22:25:00 【Xiaoyan y】
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 = 246
int fn( int a, int n ){
int i,sum=0;
for(i=0;i<n;i++){
sum+=a;
a*=10;
}
return sum;
}
int SumA( int a, int n ){
int i,count=0;
for(i=1;i<=n;i++){
count+=fn(a,i);
}
return count;
}
边栏推荐
- Basic operation and question type summary of binary tree
- STM32 development note 113:ads1258 drive design - reading temperature value
- Win10弹出USB时出现该设备正在使用的解决方法
- MATLAB点云处理(二十四):点云中值滤波(pcmedian)
- [Yu Yue education] General English of Shenyang Institute of Engineering (4) reference materials
- 360 online enterprise security cloud is open to small, medium and micro enterprises for free
- Read dense visual slam for rgb-d cameras
- crontab中定时执行shell脚本
- Optimization of quick sort
- Brief introduction to integrity
猜你喜欢

5.学城项目 支付宝支付
![[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials](/img/64/683a190d14406a9971edd79037cc97.jpg)
[Chongqing Guangdong education] college physics of Xiangtan University: mechanical and thermal reference materials

Inner join execution plan changed

Tkinter study notes (II)

Tkinter学习笔记(四)

Two methods to judge the storage of large and small end

How to adjust the font blur of win10

FastAPI 5 - 常用请求及 postman、curl 使用(parameters,x-www-form-urlencoded, raw)

Top - K problem

机器学习之Logistic回归简单实例
随机推荐
[matlab] second order saving response
926. 将字符串翻转到单调递增
一款开源的Markdown转富文本编辑器的实现原理剖析
R7-1 列表或元组的数字元素求和
MATLAB点云处理(二十五):点云生成 DEM(pc2dem)
每日一题-1317. 将整数转换为两个无零整数的和
链表基本操作与题型总结
利用SecureCRTPortable脚本功能完成网络设备的数据读取
Tkinter学习笔记(二)
Basic operation and question type summary of linked list
习题10-1 判断满足条件的三位数 (15 分)
Precision twist jitter
NLP - fastText
机器学习之线性回归简单实例
C language to achieve eight sorts (2)
Custom implementation offsetof
还在直接用 localStorage 么?该提升下逼格了
超標量處理器設計 姚永斌 第2章 Cache --2.4 小節摘錄
Use the securecrtportable script function to read data from network devices
重温c语言一