#36528: C_程式解答


Tom951121 (Tom)

學校 : 國立中正大學
編號 : 80710
來源 : [140.123.147.230]
最後登入時間 :
2023-10-20 20:26:55
j329. 絕交 -- 三國迷李牧粉題集 | From: [192.192.13.101] | 發表日期 : 2023-07-21 14:18

include <stdio.h>
#include <string.h>

int main(void) {
    char nameA[100], nameB[100], decision[4];
    fgets(nameA, sizeof(nameA), stdin);
    nameA[strcspn(nameA, "\n")] = '\0';
    fgets(nameB, sizeof(nameB), stdin);
    nameB[strcspn(nameB, "\n")] = '\0';
    fgets(decision, sizeof(decision), stdin);
    decision[strcspn(decision, "\n")] = '\0';
    if (strcmp(decision, "yes") == 0) printf("%s想和%s絕交\n", nameA, nameB);

   else if (strcmp(decision, "no") == 0) printf("%s不想和%s絕交\n", nameA, nameB);
   else  printf("輸入無效的决定\n");
    return 0;
}

 
#36529: Re: C_程式解答


Tom951121 (Tom)

學校 : 國立中正大學
編號 : 80710
來源 : [140.123.147.230]
最後登入時間 :
2023-10-20 20:26:55
j329. 絕交 -- 三國迷李牧粉題集 | From: [192.192.13.101] | 發表日期 : 2023-07-21 14:19

#include
#include

int main(void) {
    char nameA[100], nameB[100], decision[4];
    fgets(nameA, sizeof(nameA), stdin);
    nameA[strcspn(nameA, "\n")] = '\0';
    fgets(nameB, sizeof(nameB), stdin);
    nameB[strcspn(nameB, "\n")] = '\0';
    fgets(decision, sizeof(decision), stdin);
    decision[strcspn(decision, "\n")] = '\0';
    if (strcmp(decision, "yes") == 0) printf("%s想和%s絕交\n", nameA, nameB);

   else if (strcmp(decision, "no") == 0) printf("%s不想和%s絕交\n", nameA, nameB);
   else  printf("輸入無效的决定\n");
    return 0;
}



 
#36530: Re: C_程式解答


Tom951121 (Tom)

學校 : 國立中正大學
編號 : 80710
來源 : [140.123.147.230]
最後登入時間 :
2023-10-20 20:26:55
j329. 絕交 -- 三國迷李牧粉題集 | From: [192.192.13.101] | 發表日期 : 2023-07-21 14:19

#include <stdio.h>
#include <ctype.h>

int main(void) {
    char nameA[100], nameB[100], decision[4];
    fgets(nameA, sizeof(nameA), stdin);
    nameA[strcspn(nameA, "\n")] = '\0';
    fgets(nameB, sizeof(nameB), stdin);
    nameB[strcspn(nameB, "\n")] = '\0';
    fgets(decision, sizeof(decision), stdin);
    decision[strcspn(decision, "\n")] = '\0';
    if (strcmp(decision, "yes") == 0) printf("%s想和%s絕交\n", nameA, nameB);

   else if (strcmp(decision, "no") == 0) printf("%s不想和%s絕交\n", nameA, nameB);
   else  printf("輸入無效的决定\n");
    return 0;
}





 
#36531: Re: C_程式解答


Tom951121 (Tom)

學校 : 國立中正大學
編號 : 80710
來源 : [140.123.147.230]
最後登入時間 :
2023-10-20 20:26:55
j329. 絕交 -- 三國迷李牧粉題集 | From: [192.192.13.101] | 發表日期 : 2023-07-21 14:20

#include <stdio.h>
#include <string.h>

int main(void) {
    char nameA[100], nameB[100], decision[4];
    fgets(nameA, sizeof(nameA), stdin);
    nameA[strcspn(nameA, "\n")] = '\0';
    fgets(nameB, sizeof(nameB), stdin);
    nameB[strcspn(nameB, "\n")] = '\0';
    fgets(decision, sizeof(decision), stdin);
    decision[strcspn(decision, "\n")] = '\0';
    if (strcmp(decision, "yes") == 0) printf("%s想和%s絕交\n", nameA, nameB);

   else if (strcmp(decision, "no") == 0) printf("%s不想和%s絕交\n", nameA, nameB);
   else  printf("輸入無效的决定\n");
    return 0;
}







 
ZeroJudge Forum