鱼C论坛

 找回密码
 立即注册
查看: 4116|回复: 2

求助,帮我看看这个是怎么了??谢谢

[复制链接]
发表于 2013-4-30 22:41:22 | 显示全部楼层 |阅读模式
4鱼币
#include <stdio.h>
int main()
{
    int a,b,c;
while(a)
{
  printf("input 4 digits password:");
    scanf("%d",&a);
     if(999<a && a<10000)
  printf(" input normal landing\n");
  else printf("input error\n");
}
while(b)
  {
   printf("input password:");
   scanf("%d",&b);
   if(b!=a )
   { printf("password error\n");
              if(b-a==c)
   printf("input password differnce%d\n",c);                             求的是
  else    printf("password right\n");break;
   
  }
}
}      原题过程是          输入4位数的密码:              我写的两段链接不起来。。。
                                                                                      求解啊,谢谢!!!
                                输入3位---显示错误,
                               输入4位---正常,
                             输入4位---错误,
                            求输出两次输入密码的差,
                            输入密码---相同   停止;            

最佳答案

查看完整内容

在楼主的基础上改了下代码,经供参考。
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-4-30 22:41:23 | 显示全部楼层
  1. #include <stdio.h>
  2. #include <math.h>

  3. int main()
  4. {
  5.     int a,b,c;
  6.         while(1)
  7.         {
  8.                 printf("input 4 digits password:");
  9.                 scanf("%d",&a);
  10.                 if(999<a && a<10000)
  11.                 {
  12.                         printf(" input normal landing\n");
  13.                         break;
  14.                 }
  15.                 else
  16.                         printf("input error\n");
  17.         }
  18.         while(1)
  19.         {
  20.            printf("input password:");
  21.            scanf("%d",&b);
  22.            if (b>999 && b<10000)
  23.            {
  24.                    if(b!=a )
  25.                    {
  26.                            c = a-b;
  27.                        printf("input password differnce:%.0lf\n",fabs(c));                           
  28.                            }
  29.                    else
  30.                    {
  31.                            printf("password right\n");
  32.                            break;
  33.                         }
  34.            }
  35.            else
  36.            {
  37.                         printf("input error\n");
  38.            }
  39.           
  40.         }
  41. }
复制代码
在楼主的基础上改了下代码,经供参考。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-5-2 10:06:47 | 显示全部楼层
楼上太给力了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-30 08:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表