Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

6.設計程式可輸入字串,將此字串以反向輸出

0 views
Skip to first unread message

肉腳布

unread,
Jan 3, 2007, 12:18:38 AM1/3/07
to
6. 設計程式可輸入字串,將此字串以反向輸出
6. 設計程式可輸入字串,將此字串以反向輸出。例如輸入steven,則輸出nevets。(提示:宣告字元陣列來儲存字串,用迴圈計算此字串的長度後,從最後一個字元一個一個列印出來。)

#include <stdio.h>
void main()
{
char s[100];
int c=0;
printf("請輸入一個字串:");
scanf(“%s”,s);
while(s[++c]!='\0');
printf("此字串長度為:%d\n", c);
printf("其反向字串為:");
while(--c>=0)
printf(“%c”, s[c]);
}


--
◎ [1;31m龍 [32m貓 [33m資 [34m訊 [35m天 [36m地 [0m( [1mbbs.mgt.ncu.edu.tw [0m)
◎[ [1;33;46mbrucetsao [0m]From: 140.115.82.88

0 new messages