2013年7月18日木曜日

英大文字を小文字に、小文字を大文字にするプログラム


/*ひな型Hello*/
#include <stdio.h>

main(){
   char s[100]="                                                  ";
   char s1[20]="%s";
   char s2[20]="%s\n";
   char s3[20]=" input: ";
   char s4[20]="output: %s\n";
   int i;

   printf(s1,s3);
   scanf(s1,s);

   i=0;
   while(s[i]!='\0'){
      if(0x41<=s[i]&&s[i]<=0x5a) s[i]+=32;
      else if(0x61<=s[i]&&s[i]<=0x7a) s[i]-=32;
      i++;
   }
   printf(s4,s);
}

0 件のコメント:

コメントを投稿