编程知识 cdmana.com

How to do this in C language?

img




Refer to the answer 1:

Not necessarily , For reference only :

#include <ctype.h>#include <stdio.h>int main() { char s[21]; int i; fgets(s,21,stdin); s[20]=0; for (i=0;i<20;i++)  {  if (s[i]==0 || s[i]=='\n') break;  if (!isalpha(s[i]) {    printf("error");    return 1;  } } for (i=0;i<20;i++)  {  if (s[i]==0 || s[i]=='\n') break;  if (s[i]<='v' && s[i]>='a' || s[i]<='V') s[i]=s[i]+4;  else if (s[i]>'V' && s[i]<'a') s[i]=s[i]-1-'V'+'A';  else s[i]=s[i]-1-'v'+'a'; } printf("%s",s); return 0;}



Refer to the answer 2:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/10/20211025172215164p.html

Tags language
Scroll to Top