描述:
来源: pintia
正确解法一:
//嵌套 if 条件判断
#include<stdio.h>
int main()
{
float Open,High,Low,Close;
scanf("%f %f %f %f",&Open,&High,&Low,&Close);
if (Close<Open){
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 (High>Open){
printf("BW-Solid with Upper Shadow\n");
}else printf("BW-Solid");
} else if(Close==Open){
if (Low<Close){
if (High>Close){
printf("R-Cross with Lower Shadow and Upper Shadow\n");
}else printf("R-Cross with Lower Shadow\n");
} else if (High>Close) {
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 (High>Close){
printf("R-Hollow with Upper Shadow\n");
}else printf("R-Hollow\n");
return 0;
}
解法二:
//参考来源:https://blog.csdn.net/qq_32999795/article/details/53750065
#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;
}