user-0 提问: C语言题

回复:
user: user-1
content: 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10581430.html 希望对你有帮助：https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-2
content: 别乱改代码  #include<stdio.h> void mima(char* a) {     int i;      for(i = 0; i < strlen(a); i++)         if(a[i] >= 'a' && a[i] <= 'z')             a[i] = 'z' + 'a' - a[I]; else     if(a[i] >= 'A' && a[i] <= 'Z')         a[i] = 'Z' + 'A' - a[i]; } int main() {     char a[1001];     gets(a);     mima(a);     puts(a);     return 0; }

user: user-0
content: 引用 10 楼 weixin_46055651 的回复：[quote=引用 9 楼 寻开心 的回复：]把你改后的源代码再贴一下。 看起来是原文输出，根本就没有执行转换转化了，就个别没有[/quote]#include<stdio.h> void mima(char* a) {     int i;      for(i = 0; i < strlen(a); i++)         if(a[i] >= 'a' && a[i] <= 'z')             a[i] = 'z' + 'a' - a[i];;      if(a[i] >= 'A' && a[i] <= 'Z')         a[i] = 'Z' + 'A' - a[i]; } int main() {     char a[1000];     gets(a);     mima(a);     puts(a);     return 0; }

user: user-0
content: 引用 9 楼 寻开心 的回复：把你改后的源代码再贴一下。 看起来是原文输出，根本就没有执行转换转化了，就个别没有

user: user-2
content: 把你改后的源代码再贴一下。 看起来是原文输出，根本就没有执行转换

user: user-0
content: 引用 7 楼 weixin_46055651 的回复：[quote=引用 6 楼 寻开心 的回复：]没有道理。 哪些不对?   把出问题的输入数据，和正确的输出数据贴一下 贴文字，不要贴图。Expect(Line #1): 2{KUbyuvM=<1ekU?b5;]=yZGL@IQp&!elq_#iNA1+$clDzj\Z^9elbCp@fDK%Z;NEG?Fe7/v;aPz:apJoK{ZJcPRnq8htqO!T\Yo)A5Z5~r`.8G4*<onKK87ZeFJ!VH[%m,cIYO^B8FB~ys6Emjqt:v:]o,Fqa_qe*$q[Gx0u[k~(~+wme}l;LBRbEFX+_h|av\`jyX>=UKsO6Bi/aE)^'S./a3-g>`dEpNUKz-"f5C>98~8|>VNK4"1!u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x$I['(n4KLX[BMoT:}TP;oDEmzdjT-9<9CsIC#]xhwB#m6KzWzy*8t\]gw5'hi&ETPMLNW8Iv$Z3Q%lg4219f%w)cuGa!`aN&=&qRv'=zlg[3n[cq\ug9n:cB'P68>,bA}2]hg3]J'4=;c;>=B$dUqRgijhnAJJsE>%Tx1g\}A=]TL"X#doI]ihZE`6n<Ie%s.XM)dtUwxO"?ZP?DJB'-TvYTS{Uwhw((10%VoD%~Maz)r|LQG{bTt`$-'r=V6-p."7'FvDw?[Eq(p9e+_V`T0>ghBL~J6oxy+sivti2q$qyp_yXixeeuc/RM`TDgK%PXvn[E"nNU<vKSZD~);?Ud%,Pr>b5)$&=#uC<`5T378z/cNAu7>"~Rx2>Vw;f^>w8'WiQa,(~8DjW4;xg0bil"/%$*=_p-#X'pAN&M^LY`x1dEJw9kTAXfLT=<]KF!%RVk|0c2T5$PQF,u0JY-uML+I6jQ>!g1kE%1%lV4><$YW>&6,JKk@Q5R5<%nAF_i[Onw]xpc1/h~L^Fmr(+"i!%~s<h/.T9.}BCG^D]r,~,.FEbBwu2NOSpwH;ap#8VgLE{=SfYf%ki9$}bP^p87-&cMB){0WL9<u[o!ee_+}7]2Tot;Kt^&U4}7c_tRq)f!SQ>Bdye]jV_|7'b"Mr]rfp-/R`"!Mn+lu~`I(l-e~[C8iPv^kyAU1=v2~V2(b:4zebbRonh:v

user: user-0
content: 引用 6 楼 寻开心 的回复：没有道理。 哪些不对?   把出问题的输入数据，和正确的输出数据贴一下 贴文字，不要贴图。Expect(Line #1): 2{KUbyuvM=<1ekU?b5;]=yZGL@IQp&!elq_#iNA1+$clDzj\Z^9elbCp@fDK%Z;NEG?Fe7/v;aPz:apJoK{ZJcPRnq8htqO!T\Yo)A5Z5~r`.8G4*<onKK87ZeFJ!VH[%m,cIYO^B8FB~ys6Emjqt:v:]o,Fqa_qe*$q[Gx0u[k~(~+wme}l;LBRbEFX+_h|av\`jyX>=UKsO6Bi/aE)^'S./a3-g>`dEpNUKz-"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z43bW-}iaM!i)RE\vYo9Jp|{AdYTWfW&JCFt~Dc$I['(m4KLX[BMlT:}TP;lDEnawqT-9<9ChIC#]csdB#n6KaWab*8g\]td5'sr&ETPMLNW8Ie$Z3Q%ot4219u%d)xfGz!`zN&=&jRe'=aot[3m[xj\ft9m:xB'P68>,yA}2]st3]J'4=;x;>=B$wUjRtrqsmAJJhE>%Tc1t\}A=]TL"X#wlI]rsZE`6m<Iv%h.XM)wgUdcO"?ZP?DJB'-TeYTS{Udsd((10%VlD%~Mza)i|LQG{yTg`$-'i=V6-k."7'FeDd?[Ej(k9v+_V`T0>tsBL~J6lcb+hregr2j$jbk_bXrcvvfx/RM`TDtK%PXem[E"mNU<eKSZD~);?Uw%,Pi>y5)$&=#fC<`5T378a/xNAf7>"~Rc2>Vd;u^>d8'WrQz,(~8DqW4;ct0yro"/%$*=_k-#X'kAN&M^LY`c1wEJd9pTAXuLT=<]KF!%RVp|0x2T5$PQF,f0JY-fML+I6qQ>!t1pE%1%oV4><$YW>&6,JKp@Q5R5<%mAF_r[Omd]ckx1/s~L^Fni(+"r!%~h<s/.T9.}BCG^D]i,~,.FEyBdf2NOSkdH;zk#8VtLE{=SuYu%pr9$}yP^k87-&xMB){0WL9<f[l!vv_+}7]2Tlg;Kg^&U4}7x_gRj)u!SQ>Bwbv]qV_|7'y"Mi]iuk-/R`"!Mm+of~`I(o-v~[C8rPe^pbAU1=e2~V2(y:4avyyRlms:e

user: user-2
content: 没有道理。 哪些不对?   把出问题的输入数据，和正确的输出数据贴一下 贴文字，不要贴图。

user: user-0
content: 引用 4 楼 寻开心 的回复：#define LEN 1000  void mima(char * a) {     int i;     for ( i=0; i<strlen(a); i++) {         if ( a[i]>='A' && a[i] <= 'Z' )             a[i] = 'Z'+'A' - a[i];         else if ( a[i]>='a' && a[i] <= 'z' )         a[i] = 'z'+'a' - a[i];     } }  int main () {     char a[LEN+1];     gets(a);     mima(a);     puts(a);     return 0; }字符的数目是对的，就是有些字母转化的不对

user: user-2
content: #define LEN 1000  void mima(char * a) {     int i;     for ( i=0; i<strlen(a); i++) {         if ( a[i]>='A' && a[i] <= 'Z' )             a[i] = 'Z'+'A' - a[i];         else if ( a[i]>='a' && a[i] <= 'z' )         a[i] = 'z'+'a' - a[i];     } }  int main () {     char a[LEN+1];     gets(a);     mima(a);     puts(a);     return 0; }

user: user-2
content: 不超过1000位，有可能就是1000位 数组大小定义为1001； gets之后，循环里面 i的范围是 0到 strlen（a）

user: user-0
content: 引用 1 楼 寻开心 的回复：if  ( a[I] >= 'A' && a[o]<='Z' ) {       a[I]  = 'Z' - ( a[I] - 'A');     // 距离’Z'的距离的距离，是变换前距离‘A'的距离： z-newA = oldA-a   -->  newA = z - (oldA-a) } else if ( a[I] >= 'a' && a[I] <= 'z' ) {      a[I] = 'z' - (a[I] - 'a' ); }还是不行噢，跟上面结果差不多

user: user-2
content: if  ( a[I] >= 'A' && a[o]<='Z' ) {       a[I]  = 'Z' - ( a[I] - 'A');     // 距离’Z'的距离的距离，是变换前距离‘A'的距离： z-newA = oldA-a   -->  newA = z - (oldA-a) } else if ( a[I] >= 'a' && a[I] <= 'z' ) {      a[I] = 'z' - (a[I] - 'a' ); }