c语言5.0

部署运行你感兴趣的模型镜像

Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.

Input Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 10[sup]7[/sup] on each line.

Output The output contains the number of digits in the factorial of the integers appearing in the input.

Sample Input2
10
20

Sample Output7
19

#include<stdio.h> 
#include<math.h>
int main()
{
    int n,a,s=1,i,j;
 double m=0;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
   {
     s=1;
     m=0;
    scanf("%d",&a);
    for(j=1;j<=a;j++)
      {
       m=m+log10(j);
   }
  printf("%d\n",int(m+1));  
   }
   
   
}

The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.

Input The input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.

Output For each integer in the input, output its digital root on a separate line of the output.

Sample Input24
39
0

Sample Output6
3

#include<stdio.h>
#include<string.h>
int main()
{
  int n,i;
  char c[9999];
  int sum,m;
  while(scanf("%s",c)&&c[0]!='0')
  {
         sum=0;
    for( i=0;i<strlen(c);i++)
     sum+=c[i]-'0';
    while(sum>=10)
    {
      m=sum;
     sum=0;
      while(m>0)
      {
        sum+=m%10;
        m/=10;
      } 
  }
   printf("%d\n",sum);
  }
  return 0;
 } 

您可能感兴趣的与本文相关的镜像

Qwen-Image-Edit-2509

Qwen-Image-Edit-2509

图片编辑
Qwen

Qwen-Image-Edit-2509 是阿里巴巴通义千问团队于2025年9月发布的最新图像编辑AI模型,主要支持多图编辑,包括“人物+人物”、“人物+商品”等组合玩法

华为c语言编程规范5.0是华为公司针对c语言编程的一套标准化规范,旨在提高代码的质量、可维护性和可读性,从而提升软件生产效率和质量。该规范分为内容简介、命名规范、格式化规范、注释规范、函数规范、指针规范、编程实践、代码安全性和项目实施等九个方面。其中,命名规范要求给变量、函数、结构体、宏等命名时要清晰、简洁、有意义、有规律,且首字母大写等;格式化规范要求代码排版规范、缩进统一、空格使用规范等;注释规范要求代码中必须有注释、注释要精简、准确、规范、截止本行等;函数规范要求函数命名、输入输出参数、返回值等都要有规则,函数代码尽量短小精悍等;指针规范要求指针使用要规范、安全,如指针变量初始化、指针越界检查等;编程实践和代码安全性则强调程序员代码编写的态度、思考问题的角度、对代码质量重视程度等;项目实施则涉及代码的组织结构、源文件组织方式、目录管理等内容。 总体来看,华为c语言编程规范 5.0 经过多年的发展和实践,已经形成了比较完善的体系和整体框架,并不断更新完善。遵循这些规范可以提高代码的质量,使企业的软件能够更高效地开发、运行和维护。同时,这些规范也对程序员个人能力的要求更高,要求程序员注重代码的质量和规范,从而提高自己的编程素养。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值