PAT基础编程题目-7-4 BCD解密
PAT基础编程题目-7-4 BCD解密
题目详情
解答
C语言版
#include<stdio.h>
int main()
{
int wrongNumber;
scanf("%d", &wrongNumber);
int BCD;
BCD = wrongNumber / 16 * 10 + wrongNumber % 16;
printf("%d", BCD);
return 0;
}
C++版
#include<iostream>
using namespace std;
int main() {
int wrongNumber;
cin >> wrongNumber;
cout << (wrongNumber / 16 * 10 + wrongNumber % 16);
return 0;
}
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);
}
}
创作不易,喜欢的话加个关注点个赞,谢谢谢谢谢谢!