/* Sure! Below is a C program that takes a string as input, performs the operations you described on the first character, and then prints the result as a decimal value:
我做了一些修改:
A -> 取其 hex 值 41
0x41 x 0x29 x 2 = 14D2
14D2 轉成十進位 = 5330
*/
#include <stdio.h>
#include <string.h>
int hexToDecimal(char hexChar) {
if (hexChar >= '0' && hexChar <= '9')
return hexChar - '0';
else if (hexChar >= 'A' && hexChar <= 'F')
return hexChar - 'A' + 10;
else if (hexChar >= 'a' && hexChar <= 'f')
return hexChar - 'a' + 10;
else
return -1; // Invalid hex character
}
int main() {
char input[100];
printf("Enter a string: ");
scanf("%s", input);
// Check if the input string is not empty
if (strlen(input) > 0) {
char firstChar = input[0];
// int hexValue = hexToDecimal(firstChar);
int hexValue = firstChar;
if (hexValue >= 0) {
int result = (hexValue * 0x29) * 2;
printf("Hex value of first character: %X\n", hexValue);
printf("Result after multiplication and doubling: %d\n", result);
printf("The register key is : CW-%d-CRACKED\n", result);
} else {
printf("Invalid hex character: %c\n", firstChar);
}
} else {
printf("Input string is empty.\n");
}
return 0;
}
/*
Here's how the program works:
1. The user is prompted to input a string.
2. The program reads the input string.
3. It checks if the input string is not empty.
4. If the string is not empty, it takes the first character and converts it to its hexadecimal value.
5. Then, it multiplies the hexadecimal value by 0x29 and doubles the result.
6. The final result is printed as a decimal value.
Please note that this program assumes that the input contains a valid hexadecimal character. If the user enters an invalid character (not in the range of '0' to '9' or 'A' to 'F' or 'a' to 'f'), it will display an error message.
*/