牵风 发表于 2021-9-6 12:21:11

10*num是啥意思小白求问

#include <stdio.h>

int main()
{
      int ch;
      int num = 0;

      printf("请输入待转换的字符串:");

      do
      {
                ch = getchar();

                if (ch >= '0' && ch <= '9')
                {
                        num = 10 * num + (ch - '0');
                }
                else
                {
                        if (num)
                        {
                              break; // 如果已有数字,则退出循环
                        }
                }

      }
      while (ch != '\n');

      printf("结果是:%d\n", num);

      return 0;
}

Max472 发表于 2021-9-6 12:38:39

就是 10 * num   
这是乘号

大马强 发表于 2021-9-6 16:50:25

10*num
表示 10 乘上 num
此外,除号 -> /
求余 -> %
页: [1]
查看完整版本: 10*num是啥意思小白求问