2013年1月4日 星期五

[ZJ] a001. 哈囉

內容 :
學習所有程式語言的第一個練習題
請寫一個程式,可以讀入指定的字串,並且輸出指定的字串。
輸入說明 :
指定的文字
輸出說明 :
輸出指定的文字
範例輸入 :
worldC++mary
範例輸出 :
hello, worldhello, C++hello, mary

/**********************************************************************************/
/*  Problem: a001 "哈囉" from Brian Kernighan                                   */
/*  Language: C                                                                   */
/*  Result: AC (4ms, 254KB) on ZeroJudge                                          */
/*  Author: restart at 2011-04-04 16:18:23                                        */
/**********************************************************************************/


#include<stdio.h>
#include<stdlib.h>
main()
{
    char S[100]; 
    while(scanf("%s",S)==1) 
        printf("hello, %s\n",S); 
    return 0;
}
/**********************************************************************************/
/*  Problem: a001 "哈囉" from Brian Kernighan                                   */
/*  Language: C                                                                   */
/*  Result: AC (0ms, 254KB) on ZeroJudge                                          */
/*  Author: restart at 2011-04-04 16:19:57                                        */
/**********************************************************************************/


#include<stdio.h>
main()
{
    char S[100]; 
    while(scanf("%s",S)!=EOF) 
        printf("hello, %s\n",S); 
    return 0;
}
/**********************************************************************************/
/*  Problem: a001 "哈囉" from Brian Kernighan                                   */
/*  Language: C                                                                   */
/*  Result: AC (2ms, 230KB) on ZeroJudge                                          */
/*  Author: restart at 2011-04-04 16:23:35                                        */
/**********************************************************************************/


#include<stdio.h>
main()
{
    char S[100]; 
    while(gets(S)) 
        printf("hello, %s\n",S); 
    return 0;
}

沒有留言:

張貼留言