12、求Sn = a + aa + aaa + aaaa + ....其中a为一个数字,一共有n项。a和n由用户键盘输入。
2024-09-08 17:16:34
/*
求Sn = a + aa + aaa + aaaa + ....其中a为一个数字,一共有n项。a和n由用户键盘输入。
*/
#include <stdio.h>
#include <stdlib.h>
void anFunc()
{
int Sn =0,p = 0;
int a,n;
printf("Enter a:\n");
scanf("%d", &a);
printf(("Enter n:\n"));
scanf("%d", &n);
while(n--)
{
p = p*10 + a;
Sn = Sn + p;
}
printf("%d", Sn);
}
int main()
{
anFunc();
return 0;
}
最新文章
- 用Python制作新浪微博爬虫
- jquery实现轮播图
- C语言学习008:标准错误
- 【HTML】字符(Glyphs)收集
- zencart资源
- Spring学习总结(1)——Spring AOP的概念理解
- codeforces 432 B Football Kit
- 牛客_Java_值传递(拷贝)不该表原来变量+传引用的话会一起改变
- linux之uniq
- spring02IOC
- GridView下DropDownList 的选择方法onselectedindexchanged 实现方法
- Yogurt factory(POJ 2393 贪心 or DP)
- vector 汇总
- Codeforces 110B-Lucky String(技能)
- Android -- 从源码的角度一步步打造自己的TextView
- 用greenlet实现Python中的并发
- 51nod 1686 第k大区间
- [日常]总结2016年7月入职至2016年7月26号微盘所遇bug
- router-link 自定义点击事件
- Linux网络编程学习计划