当前位置:网站首页>Notes on writing questions in C language -- find s=a+aa+aaa+aaaa+aa Value of a
Notes on writing questions in C language -- find s=a+aa+aaa+aaaa+aa Value of a
2022-06-21 19:06:00 【Fanyi】

List of articles
subject
Calculation s = a + aa + aaa + aaaa +…+ aa…a Value .
among a It's a number .
for example 2+22+222+2222+22222( At this time, there is 5 Add up the numbers ), The sum of several numbers is controlled by the keyboard .
Ideas
Calculate and add the values of each item by using the circular statement .
Answer key
#include <stdio.h>
int main()
{
int a,n,count=1;
long int sn=0,tn=0;
printf(" Please enter a and n:");
scanf("%d %d",&a,&n);
while(count<=n)
{
tn=tn+a;
sn=sn+tn;
a=a*10;
++count;
}
printf("s=%ld\n",sn);
}
Sample output



边栏推荐
- canvas交互式颜色渐变js特效代码
- Deep Copy
- How to apply for SSL certificate using IP
- 大佬们,麻烦问一个flink sql的问题,我有一个fql语句,insert into c sele
- Servlet学习(二)
- R language bug? report errors? As for the outcome of sub variables 0 and 1, the original content of the outcome variable is changed through the process of factor and numeric?
- Book at the end of the article | new work by teacher Li Hang! A new upgrade of the classic machine learning work statistical learning methods
- The best network packet capturing tool mitmproxy
- 写着玩的处理框架
- Canvas球体粒子变幻颜色js特效
猜你喜欢

数据库主键一定要自增吗?有哪些场景不建议自增?

Image classification, AI and automatic performance test

Full screen menu animation effect expansion in the upper left corner of SVG

JDBC notes

Day10QRadiobutton2021-09-24

Start! Alibaba programming summer 2022

In the new season, China Super League and Guoan are moving forward amid thorns

jvm造轮子

De « l'entreprise gérée par le village » au « Groupe de 10 milliards de yuans », comment l'industrie Hongxing complète - t - elle le « changement de papillon »?

删除指定的screen
随机推荐
36氪首发 | 聚焦健康险产品创新,「英仕健康」已获4轮融资
协同过滤(Collaborative Filtering)
Leetcode(210)——课程表 II
ThreeJS飞机地球3D场景动画
2021-10-26 metagenome analysis (personal note 2)
JDBC Basics
Product graphic list description layout style
【艾思软件】微信小程序开发报价方案模版
Threejs aircraft Earth 3D scene animation
Servlet规范(一)
新赛季的中超和国安,荆棘中前行
Explanation of El table paging select all function
蓝色SVG波浪动态网页背景
Canvas动态网状背景js特效
Canvas dynamic mesh background JS effect
JSP Basics
启动!阿里巴巴编程之夏2022
产品图文列表说明布局样式
空中操作仅通过距离映射对遮挡目标进行鲁棒定位(RAL2022)
Compound type of typescript