7-13 日K蜡烛图(15 分)

自己做的,利用了if循环,但是是错的

#include<stdio.h>
int main(){
    double open,high,low,close;

    scanf("%lf %lf %lf %lf",&open,&high,&low,&high);
    if(open>close){
      if(low<close){
        if(high>open){
            printf("BW-Solid with lower shadow and upper shadow\n");
          }
         else printf("BW-Solid with lower shadow\n");
      }
      else if(low>close){
        if(high>open)printf("BW-Solid with upper shadow\n");
        else printf("BW-Solid\n");
      }
}
    else if(open==close){
        if(low<close){
        if(high>open){
            printf("R-Cross with lower shadow and upper shadow\n");
          }
         else printf("R-Cross with lower shadow\n");
      }
      else if(low>close){
        if(high>open)printf("R-Cross with upper shadow\n");
        else printf("R-Cross\n");
      }     
    }
    else{
            if(low<open){
        if(high>close){
            printf("R-Hollow with lower shadow and upper shadow\n");
          }
         else printf("R-Hollow with lower shadow\n");
      }
      else if(low>open){
        if(high>close)printf("R-Hollow with upper shadow\n");
        else printf("R-Hollow\n");
      }     
}
    return 0;
}

转别人的

#include<stdio.h>
int main()
{
    double open,close,high,low;
    scanf("%lf %lf %lf %lf",&open,&high,&low,&close);

    {
        if(close<open)
        printf("BW-Solid");
    else if(close>open)
        printf("R-Hollow");
    else
        printf("R-Cross");
    }

    {//上下影线都存在的情况,记得加上前面的空格
    if((low<open&&low<close)&&(high>open&&high>close))
        printf(" with Lower Shadow and Upper Shadow");
     //下影线
    else if(low<open&&low<close)
        printf(" with Lower Shadow");
    //上影线
    else if(high>open&&high>close)
        printf(" with Upper Shadow");

    }
        return 0;
}

首先,printf可以分开来(原来!),其次,当说high的时候就是比close和open都大。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值