PAT基础编程题目-7-13 日K蜡烛图
PAT基础编程题目-7-13 日K蜡烛图
题目详情
解答
C语言版
#include<stdio.h>
int main() {
float open, high, low, close;
scanf("%f %f %f %f", &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;
}
C++版
#include<iostream>
using namespace std;
int main() {
float open, high, low, close;
cin >> open >> high >> low >> close;
if (close < open)
cout << "BW-Solid";
else if (close > open)
cout << "R-Hollow";
else
cout<< "R-Cross";
if (low < open && low < close && high > open&& high > close)
cout << " with Lower Shadow and Upper Shadow";
else if (low < open && low < close)
cout << " with Lower Shadow";
else if (high > open&& high > close)
cout << " with Upper Shadow";
return 0;
}
Java版
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
float open = 0, high = 0, low = 0, close = 0;
Scanner scanner = new Scanner(System.in);
if (scanner.hasNext()) {
open = scanner.nextFloat();
high = scanner.nextFloat();
low = scanner.nextFloat();
close = scanner.nextFloat();
}
scanner.close();
if (close < open)
System.out.print("BW-Solid");
else if (close > open)
System.out.print("R-Hollow");
else
System.out.print("R-Cross");
if (low < open && low < close && high > open&& high > close)
System.out.print(" with Lower Shadow and Upper Shadow");
else if (low < open && low < close)
System.out.print(" with Lower Shadow");
else if (high > open&& high > close)
System.out.print(" with Upper Shadow");
}
}
创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!