פורסם 2013 באוגוסט 2212 שנים מעבר מאות גדולה לקטנה מתבצע באופן תקין אבל מעבר מקטנה לגדולה לא מצליח לי, אני לא מבין למה, ניסיתי כמה אופציות ולא הלך לי אני בטח מפספס משהו אני יודע שההפרש בין התווים האסקיים הוא 32 כלומר שאם ישנה אות גדולה ואוסיף לה 32 אקבל את אותה האות אבל קטנה וכן אם אחסיר 32 מהערך האסקי אקבל את האות הגדולה בהתאמה וזה מה שעשיתי אבל אני מקבל אות בגיבריש כזו אשמח לעזרה מצורף הקוד אפשר להתעלם מהשטויות מסביב ולהתייחס לקטע בו יש מספר מצבים[FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]{[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][COLOR=blue][FONT=Consolas]char[/FONT][/COLOR][FONT=Consolas] tav1,tav2;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][COLOR=blue][FONT=Consolas]int[/FONT][/COLOR][FONT=Consolas] n1,n2;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]printf([COLOR=#A31515]"press one key at keyboard after press enter \n"[/COLOR]);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]scanf([COLOR=#A31515]"%c"[/COLOR],&tav1);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]flushall();[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]printf([COLOR=#A31515]"press one key at keyboard after press enter \n"[/COLOR]);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas]scanf([COLOR=#A31515]"%c"[/COLOR],&tav2);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][COLOR=green][FONT=Consolas]//n1=tav1;n2=tav2;[/FONT][/COLOR][FONT=Consolas][/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][COLOR=blue][FONT=Consolas]if[/FONT][/COLOR][FONT=Consolas]((tav1>=[COLOR=#A31515]'A'[/COLOR]&& tav1<=[COLOR=#A31515]'Z'[/COLOR]|| tav1>=[COLOR=#A31515]'a'[/COLOR] && tav1<=[COLOR=#A31515]'z'[/COLOR])&&(tav2>=[COLOR=#A31515]'A'[/COLOR]&& tav2<=[COLOR=#A31515]'Z'[/COLOR]|| tav2>=[COLOR=#A31515]'a'[/COLOR] && tav2<=[COLOR=#A31515]'z'[/COLOR]))[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] {[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] [COLOR=blue]if[/COLOR](tav1>=[COLOR=#A31515]'A'[/COLOR] || tav1<=[COLOR=#A31515]'Z'[/COLOR])[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] tav1+=32;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] [COLOR=blue]else[/COLOR][/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] tav1=tav1-32;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] [COLOR=blue]if[/COLOR](tav2>=[COLOR=#A31515]'A'[/COLOR]||tav2<=[COLOR=#A31515]'Z'[/COLOR])[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] tav2+=32;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] [COLOR=blue]else[/COLOR][/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] tav2=tav2-32;[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] printf([COLOR=#A31515]"you pressed %c \t key his ascii value is %d \n"[/COLOR],tav1,tav1);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] printf([COLOR=#A31515]"you pressed %c \t key his ascii value is %d \n"[/COLOR],tav2,tav2);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] }[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][COLOR=blue][FONT=Consolas]else[/FONT][/COLOR][FONT=Consolas][/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] printf([COLOR=#A31515]"one or both inputs are not type\n"[/COLOR]);[/FONT][/LEFT][FONT=Times New Roman] [/FONT][LEFT][FONT=Consolas] [/FONT][/LEFT][FONT=Times New Roman] [/FONT][FONT=Consolas]}[/FONT]
פורסם 2013 באוגוסט 2212 שנים מחבר תסתכל על ה-if שבו אתה בודק אם האות קטנה או גדולה. אויי איך פספסתי את זה התנאי צריך להיות וגם if(tav1>='A' && tav1<='Z') tav1+=32; else tav1=tav1-32; if(tav2>='A'&& tav2<='Z') tav2+=32; else tav2=tav2-32; - - - תגובה אוחדה: - - -זה רק אצלי או שגם אצלכם העריכה עובדת ממש ממש לאט? (זה קורה לי רק HWZONE) הקלדתי בWORD והדבקתי..
פורסם 2013 באוגוסט 2212 שנים דרך קצת יותר ברורה להפוך אות גדולה לקטנה: if (ch >= 'A' && ch <= 'Z') ch = ch - 'A' + 'a'; היתרון הוא שלא צריך להבין מה ההפרש בין 'A' ל-'a' והאם הוא חיובי או לא. הקומפיילר דואג לזה. גם קל יותר לקרוא את הקוד.
פורסם 2013 בספטמבר 1112 שנים או ביטי:ch^0x20 - יחליף גדול לקטן וההפך.למה? שים לב למרחק בין האותיות הגדולות לקטנות ב-ASCII
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.