如何仅考虑int编号的第一个n密码?

发布于 2025-02-11 23:42:23 字数 1398 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡的优雅 2025-02-18 23:42:23

您可以在循环时使用DO。我相信密码仅在7和8上进行编码。如果您仍然继续进行,则可以继续添加代码。据我所知,我试图在此处进行代码,

#include <stdio.h>
int main() {
  long long n;
  int num=3;
  int count=0;
  printf("Enter an integer: ");
  scanf("%lld", &n);
  if(n>9999999)
  {
      num=4;
  }
  printf("Number of cipher: %d", num);
  // iterate at least once, then until n becomes 0
  // remove last digit from n in each iteration
  // increase count by 1 in each iteration
  do {
    n /= 10;
    count++;
  } while (count!=num);
  if(count==3)
  {
      n/=10;
  }
  printf("Number of cipher: %lld", n);
}

you can make use do while loop. I believe cipher codified only on 7 and 8. If you still continue you can keep adding the code. As far as I understood, i tried to put into code here,

#include <stdio.h>
int main() {
  long long n;
  int num=3;
  int count=0;
  printf("Enter an integer: ");
  scanf("%lld", &n);
  if(n>9999999)
  {
      num=4;
  }
  printf("Number of cipher: %d", num);
  // iterate at least once, then until n becomes 0
  // remove last digit from n in each iteration
  // increase count by 1 in each iteration
  do {
    n /= 10;
    count++;
  } while (count!=num);
  if(count==3)
  {
      n/=10;
  }
  printf("Number of cipher: %lld", n);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文