PAT基础编程题目-7-13 日K蜡烛图

PAT基础编程题目-7-13 日K蜡烛图

题目详情

题目地址:https://pintia.cn/problem-sets/14/problems/793

解答

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");

	}

}

创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!

全部评论

相关推荐

去B座二楼砸水泥地:不过也可以理解,这种应该没参加过秋招
点赞 评论 收藏
分享
冷艳的小师弟在看机会:jd测评乱点直接被挂了,哭死~
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务