#1263: 為什麼還是少個空白?那裡判斷錯呢?


deepking (deepking)

學校 : 不指定學校
編號 : 2206
來源 : [114.27.131.5]
最後登入時間 :
2014-01-17 06:09:37
c045. 00490 - Rotating Sentences -- UVa490 | From: [122.122.37.98] | 發表日期 : 2009-01-27 20:09

#include<stdio.h>
#define MAX 100

int main(void)
{
    char ch;
    int sc = 0;
    int ac = 0;
    int max_ac = 0;
    int i,j;
    char t[MAX][MAX] = {'\0'};

    while(scanf("%c", &ch) != EOF)
    {   
        if(ch == '\n')
        {   
            if(ac > max_ac)
                max_ac = ac;
            if(ac == 0)
                t[sc][ac] = ' ';
            ac = 0;  
            sc++;
        }   
        else
        {   
            t[sc][ac++] = ch;
        }   
    }   
    sc--;
    for(ac = 0; ac < max_ac; ac++)
    {   
        for(i = sc; i >= 0; i--)
        {   
            if(t[i][ac] != '\0')
                printf("%c", t[i][ac]);
        }   
        printf("\n");
    }   

    return 0;
}
 
ZeroJudge Forum