輸入:Hello World!其實就只是照實印出,但要注意的就是「\\」和「\"」字元,印出時前面要多加「\\」。C 語言程式碼如下:
輸出:#include<string.h>
#include<stdio.h>
int main()
{
printf("Hello World!\n");
printf("\n");
return 0;
}
int n, caseNum = 1, i, j;
char ch; char str[101];
while (scanf("%d", &n) == 1 && n)
{
printf("Case %d:\n#include<string.h>\n#include<stdio.h>\nint main()\n{\n", caseNum ++);
getchar();
while (n --)
{
gets(str);
printf( "printf(\"" );
for (i = 0; str[i]; i ++)
{
if (str[i] == '\\' || str[i] == '\"')
printf("\\%c", str[i]);
else
printf("%c", str[i]);
}
printf("\\n\");\n");
}
printf("printf(\"\\n\");\nreturn 0;\n}\n");
}
By David.K
p11483題目連結
回ACM題庫目錄
回首頁
沒有留言:
張貼留言