#include <stdio.h>
#include <string.h>
#define MAX 101
char arr[MAX][MAX] ;
int main(int argc, char *argv[])
{
memset(arr, '\0', sizeof(arr) ) ;
int i, j ;
int rows = 0;
int cols = 0 ;
for (i=0; fgets(arr[i], sizeof(arr[i]), stdin) != NULL ; ++i)
rows++ ;
char *pos ;
for (i=0 ; arr[i][0]!='\0'; ++i)
{
if ((pos=strchr(arr[i], '\n')) != NULL)
*pos = '\0';
if (strlen(arr[i]) > cols)
cols = strlen(arr[i]) ;
}
for (i=0; i<cols; ++i)
{
for (j=rows-1; j>=0 ; --j)
printf("%c",(arr[j][i]=='\0'?' ':arr[j][i])) ;
puts("") ;
}
return 0;
}
(defparameter arr (make-array '(100) :initial-element nil))
(defparameter rows 0)
(defparameter cols 0)
(defun read-lines ()
"read lines until eof"
(do ((i 0 (incf i) )
(line (read-line *standard-input* nil 'eof)
(read-line *standard-input* nil 'eof)))
((eql line 'eof) i)
(setf (aref arr i) line)))
(defun max-len-str()
(let (( max -1 ))
(do ((i 0 (incf i)))
((>= i rows) max)
(if ( > (length (aref arr i)) max )
(setf max (length (aref arr i)))))))
(defun printf()
(do ((i 0 (incf i)) )
((>= i cols))
(do ((j (- rows 1) (decf j)))
((< j 0))
(if (> (length (aref arr j)) i)
(princ (aref (aref arr j) i))
(princ " ") ))
(princ #\Newline)))
(defun rotate-string()
(setf rows (read-lines))
(setf cols (max-len-str))
(printf))
(rotate-string)
題目連結:http://zerojudge.tw/ShowProblem?problemid=c045