pta刷题前看了翁恺老师讲的字符串部分,本着活学活用的原则,创造了第一个无法跑起来的及其复杂代码,并且逻辑混乱(꒪⌓꒪)
有时间再尝试补救~~
另:正解为:(3条消息) 7-13 日K蜡烛图 (15 分)_小白程序员丶钟同学的博客-CSDN博客_日k蜡烛图
屎山如下:
#include <stdio.h>//此代码目前跑不动
#include <string.h>
int main()
{
double open,high,low,close;
char s1[9] = "BW-Solid";
char s2[9] = "R-Hollow";
char s3[20] = " Lower Shadow";
char s4[20] = " Upper Shadow";
char s5[5] = " with";
char s6[5] = " and";
char s7[9] = "R-Cross";
scanf("%lf",&open,&high,&low,&close);
if(close<open){
if(low<open&&low<close){
if(high>open&&high>close){
strcat(s1,s5);
strcat(s1,s3);
strcat(s1,s6);
strcat(s1,s4);
printf("%s",s1);
}
else{
strcat(s1,s5);
strcat(s1,s3);
printf("%s",s1);
}
}
else if(high>open&&high>close){
strcat(s1,s5);
strcat(s1,s4);
printf("%s",s1);
}
else{
printf("%s",s1);
}
}
else if(close>open){
if(low<open&&low<close){
if(high>open&&high>close){
strcat(s2,s5);
strcat(s2,s3);
strcat(s2,s6);
strcat(s2,s4);
printf("%s",s2);
}
else{
strcat(s2,s5);
strcat(s2,s3);
printf("%s",s2);
}
}
}
else{
if(low<open&&low<close){
if(high>open&&high>close){
strcat(s7,s5);
strcat(s7,s3);
strcat(s7,s6);
strcat(s7,s4);
printf("%s",s7);
}
else{
strcat(s7,s5);
strcat(s7,s3);
printf("%s",s7);
}
}
}
return 0;
}