欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

PAT基础编程题目-7-4 BCD解密

程序员文章站 2022-06-08 13:15:41
...

PAT基础编程题目-7-4 BCD解密

题目详情

PAT基础编程题目-7-4 BCD解密

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

解答

C语言版

#include<stdio.h>
int main()
{
	int wrongNumber;
	scanf("%d", &wrongNumber);
	int BCD;
	BCD = wrongNumber / 16 * 10 + wrongNumber % 16;
	printf("%d", BCD);
	return 0;
}

PAT基础编程题目-7-4 BCD解密

C++版

#include<iostream>
using namespace std;
int main() {
	int wrongNumber;
	cin >> wrongNumber;
	cout << (wrongNumber / 16 * 10 + wrongNumber % 16);
	return 0;
}

PAT基础编程题目-7-4 BCD解密

Java版

import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		int wrongNumber = 0;
		Scanner scanner = new Scanner(System.in);
		if (scanner.hasNext()) {
			wrongNumber = scanner.nextInt();
		}
		scanner.close();
		System.out.println(wrongNumber / 16 * 10 + wrongNumber % 16);

	}

}

PAT基础编程题目-7-4 BCD解密

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