#9079: 為什麼一直WA


tony1102105341 (硬梆梆俱樂部會長)


第 1 測資點(0%): WA (line:3) 
答案不正確
您的答案為: *DEC is the trademark of the Digital Equipment Corporation.orpor ...略 正確答案為: *DEC is the trademark of the Digital Equipment Corporation.
 為什麼前面對,但是後面會多一小串  我在測試的時候沒問題

 下是我的程式碼

#include<stdio.h> #include<stdlib.h> int main() { 	int i=0; 	char input[101] = {0}; 	char output[101] = {0}; 	while (scanf("%s", input)==1) 	{ 		for (int i = 0; i < 101; i++) 		{ 			if ((int)input[i] != 0) 				output[i] = (int)input[i] - 7; 		} 		for (int i = 0; i < 101; i++) 		{ 			if ((int)output[i] != 0) 				printf("%c", output[i]); 		} 		printf("\n"); 	} 	return 0; }
 
#9080: Re:為什麼一直WA


anandrewboy70900 (ShowTsai)


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

int main() 
{
    int i;
    char input[101] = {0};
    char output[101] = {0};
    while (scanf("%s", input)==1)
    {
        for (i = 0; i < strlen(input); i++)
        {
            if ((int)input[i] != 0)
            output[i] = (int)input[i] - 7;
        }
        for (i = 0; i < strlen(input); i++)
        {
            if ((int)output[i] != 0)
            printf("%c", output[i]);
        }
        printf("\n");
    }
    return 0; 
}
 
我幫你加上計算字串長度(strlen)的函數~~~