安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

C语言实现求S=a+aa+aaa+...+aa...a的值

  • 日期: 2025-10-31
  • 标签: 常规

#include <stdio.h>

int main() { int a,n; long int sn=0,tn=0; int count = 1;

printf('please input a and n\n');
scanf('%d,%d',&a,&n);
printf('a=%d, n=%d\n',a,n);

while(count <= n) {
    tn = tn + a;
    sn = sn + tn;
    a = a * 10;
    count++;
}

printf('a+aa+...=%ld\n',sn);
return 0;

}

C语言实现求S=a+aa+aaa+...+aa...a的值

原文地址: https://www.cveoy.top/t/topic/pXyf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: C Program to Calculate the Sum of Factorials of Even Numbers
  • 下一篇: 激光加工技术实训体会:提升效率、开拓未来

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2