啊哈磊_编程从这里起步

标题: 【第三章第6节】动手试一试 题解 [打印本页]

作者: rosynirvana    时间: 2014-4-21 18:21
标题: 【第三章第6节】动手试一试 题解
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.         int a,b,c,d;
  6.         scanf("%d %d %d",&a,&b,&c);
  7.         if(a<b)
  8.                 d=a;
  9.         else
  10.                 d=b;

  11.         if(d<c)
  12.                 printf("%d",d);
  13.         else
  14.                 printf("%d",c);
  15.         
  16.         system("pause");
  17.         return 0;
  18. }
复制代码

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.         int a,b,c,d,e;
  6.         scanf("%d %d %d %d",&a,&b,&c,&d);
  7.         if(a>b)
  8.                 e=a;
  9.         else
  10.                 e=b;

  11.         if(e<c)
  12.                 e = c;

  13.         if(e<d)
  14.                 e = d;
  15.         printf("%d",e);
  16.         
  17.         system("pause");
  18.         return 0;
  19. }
复制代码

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.         int a;
  6.         scanf("%d",&a);
  7.         if((a%4==0 && a%100!=0) || (a%400==0))
  8.                 printf("yes");
  9.         else
  10.                 printf("no");
  11.         
  12.         system("pause");
  13.         return 0;
  14. }
复制代码


作者: cad20020601    时间: 2014-5-25 09:47
                                 
作者: wbb325    时间: 2014-9-27 15:01
第2题,比较出4个整数的最大值,这么写行不行?
#include <stdio.h>
#include <stdlib.h>
int main()
{
        int a,b,c,d,temp1,temp2;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<b)        temp1=b;
    else        temp1=a;
    if(c<d) temp2=d;
    else        temp2=c;
    if(temp1<temp2)        printf("%d",temp2);
    else        printf("%d",temp1);
        system("pause");
        return 0;
}
反正编译是没问题的!
作者: rosynirvana    时间: 2014-9-27 15:22
wbb325 发表于 2014-9-27 15:01
第2题,比较出4个整数的最大值,这么写行不行?
#include
#include

可以的
作者: 失忆蝴_JL0rl    时间: 2017-6-3 00:15
第一题后面这样写是不是也可以
#include <stdio.h>
#include <stdlib.h>
int main()
{
        int a,b,c,d;
        scanf("%d %d %d",&a,&b,&c);
        if(a<b)
                d=a;
        else
                d=b;

        if(c<d)
                d=c;
        printf("%d",d);
        
        system("pause");
        return 0;
}




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2