2009-12-30 18:13:25來源不明

奇摩知識+ C語言字串反轉 大小寫互換

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
  char S[5000];
  while(scanf("%s",S)==1) //輸入字串
      {
         int a,N=strlen(S); //用內建抓看輸入的字元個數
         for(a=N-1;a>=0;a--)// 從後面開始輸出
             if(S[a]>='a')  //大小寫轉換
               printf("%c",S[a]-'a'+'A');
             else
               printf("%c",S[a]-'A'+'a');
          puts("");
      }
 return 0;  
}