/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C/C++.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <ctype.h>
void getAbbreviation(char* name, char* abbre) {
int j = 0; // Chỉ số cho chuỗi abbre
// Lặp qua từng ký tự trong chuỗi name
for (int i = 0; name[i] != '\0'; i++) {
// Nếu ký tự là chữ cái đầu của từ (sau khoảng trắng hoặc đầu chuỗi)
if (i == 0 || (name[i - 1] == ' ' && name[i] != ' ')) {
abbre
[j
++] = toupper(name
[i
]); // Lấy ký tự viết hoa vào abbre }
}
abbre[j] = '\0'; // Kết thúc chuỗi viết tắt
}
int main() {
char name[100] = "Cong ty Phan mem OpenAI";
char abbre[10]; // Chuỗi chứa tên viết tắt (kích thước đủ lớn)
getAbbreviation(name, abbre);
printf("Abbreviation: %s\n", abbre
);
return 0;
}
LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoKV2VsY29tZSB0byBHREIgT25saW5lLgpHREIgb25saW5lIGlzIGFuIG9ubGluZSBjb21waWxlciBhbmQgZGVidWdnZXIgdG9vbCBmb3IgQy9DKysuCkNvZGUsIENvbXBpbGUsIFJ1biBhbmQgRGVidWcgb25saW5lIGZyb20gYW55d2hlcmUgaW4gd29ybGQuCgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPGN0eXBlLmg+Cgp2b2lkIGdldEFiYnJldmlhdGlvbihjaGFyKiBuYW1lLCBjaGFyKiBhYmJyZSkgewogICAgaW50IGogPSAwOyAvLyBDaOG7iSBz4buRIGNobyBjaHXhu5dpIGFiYnJlCgogICAgLy8gTOG6t3AgcXVhIHThu6tuZyBrw70gdOG7sSB0cm9uZyBjaHXhu5dpIG5hbW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