| 2 | 1/1 | 返回列表 |
| 查看: 539 | 回復: 1 | |||
苒葉楓鐵桿木蟲 (正式寫手)
|
[交流]
【求助】C語言上機編程。。。!居行谥2010年9月17日】
|
|
計算機3級網(wǎng)絡技術上機試題(ASCII碼左移以及相關邏輯判斷) 題干如下 實現(xiàn)StrCharJL()函數(shù)功能為:以行為單位把字符串種的所有字符的ASCII值左移4位,如果左移后,其字符的ASCII值小于等于32或大于100,則原字符保持不變;否則把左移后的字符ASCII值再加上原字符的ASCII值,得到的新字符仍然存入到原字符串對應的位置。最后把已處理的字符串仍按行重新存入字符串數(shù)組XX中 #include #include #include char xx[50][80]; int maxline=0; int ReadDat(void); void WriteDat(void); void StrCharJL(void) { } void main() { system("CLS" ;if(ReadDat()) { printf("數(shù)據(jù)文件IN.DAT不能打開\n\007" ; return; } StrCharJL(); WriteDat(); } int ReadDat(void) { FILE *fp; int i=0; char *p; if((fp=fopen("IN.DAT","r" )==NULL) return 1;while(fgets(xx,80,fp)!=NULL) { p=strchr(xx,'\n'); if(p) *p=0; i++; } maxline=i; fclose(fp); return 0; } void WriteDat(void ) { FILE *fp; int i; system("CLS" ;fp=fopen("OUT.DAT","w" ;for(i=0;i printf("%s\n",xx); fprintf(fp,"%s\n",xx); } fclose(fp); } 源文件中文章為: Economic development will inevitably generate industrial waste which in turn will cause pollution to the living environment. Economic prosperity and a clean environment can not coexist. You have to make a choice between the two 答案給出結果為: void StrCharJL(void) { int i,j; /*定義循環(huán)控制變量*/ int str; char ch; for(i=0;i str=strlen(xx); /*求得當前行的字符串長度*/ for(j=0;j ch=xx[j]<<4; if(ch<=32 || ch>100) continue; /*如果左移4位后字符的ASCII值小于等于32或大于100,則原字符保持不變*/ else xx[j]+=4; /*否則就把左移后的字符ASCII值加上原字符的ASCII*/ } } } 文件變?yōu)?br /> Igonomig hizilopminx will inizixably giniraxi inhywxrial wawxi whigh in xyrn will gaywi pollyxion xo xhi lizing inzironminx. Igonomig prowpirixy anh a glian inzironminx gan nox goixiwx. Yoy hazi xo maki a ghoigi bixwiin xhi xwo 感覺答案不對,按自己的思路運行結果又是亂碼,求高手指教,希望附上調試結果,謝謝。 這是我自己做的。好像也沒什么錯誤啊。可是運行的結果卻。。。。 void StrCharJL(void) { int i,j; int k; for(i=0;i for(j=0;j continue; else xx[j]+=xx[j]<<4; } } } 結果: 晸onomi?velopment will inevitq俵y generqte instriql wqste whi揾 in turn will 搎use pollution to the living environment 晸onomi?prosperity qn?q 搇eqn environment 搎n not 搊exist 閛u hqve to mqke q 揾oi揺 俥tween the two [ Last edited by 苒葉楓 on 2010-9-14 at 10:38 ] |

鐵桿木蟲 (正式寫手)

| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 273求調劑 +19 | 李芷新1 2026-03-31 | 19/950 |
|
|---|---|---|---|---|
|
[考研] 379求調劑 +3 | ?苦瓜不苦 2026-04-01 | 3/150 |
|
|
[考研] 324分 085600材料與化工 +17 | 呆鵝oor 2026-03-27 | 17/850 |
|
|
[考研] 材料0856 英一數(shù)二 323 求調劑 +9 | 袁sy 2026-04-01 | 9/450 |
|
|
[碩博家園] 博一被送出聯(lián)培感覺不適應怎么辦 +3 | 全村的狗 2026-03-31 | 3/150 |
|
|
[考研] 求0861交通運輸專碩or材料專碩調劑 +4 | 勒布朗@ 2026-03-31 | 4/200 |
|
|
[考研] 309分085801求調劑 +7 | 學員Gtwj7W 2026-03-31 | 7/350 |
|
|
[考研] 一志愿華東師范大學有機化學專業(yè),初試351分,復試被刷求調劑! +9 | 真名有冰 2026-03-29 | 10/500 |
|
|
[考研] 0703化學 +20 | 妮妮ninicgb 2026-03-27 | 20/1000 |
|
|
[考研] 081200-11408-276學碩求調劑 +4 | 崔wj 2026-03-31 | 4/200 |
|
|
[考研] 08工科,295,接受跨專業(yè)調劑 +6 | lmnlzy 2026-03-30 | 6/300 |
|
|
[考研] 085600,專業(yè)課化工原理,320分求調劑 +6 | 大饞小子 2026-03-29 | 6/300 |
|
|
[考研] 281求調劑 +5 | 亞克西good 2026-03-26 | 7/350 |
|
|
[考研] 332求調劑 +6 | @MZB382400 2026-03-28 | 6/300 |
|
|
[考研] 071010 323 分求調劑 +3 | Baekzhy 2026-03-27 | 3/150 |
|
|
[考研] 一志愿雙一流機械285分求調劑 +4 | 幸運的三木 2026-03-29 | 5/250 |
|
|
[考研] 086000生物與醫(yī)藥調劑 +5 | Feisty。 2026-03-28 | 9/450 |
|
|
[考研] 085602 化工專碩 338分 求調劑 +12 | 路癡小琪 2026-03-27 | 12/600 |
|
|
[考研] 394求調劑 +3 | 好事多磨靜候佳?/a> 2026-03-26 | 5/250 |
|
|
[考研] 環(huán)境專碩324分求調劑推薦 +5 | 軒小寧—— 2026-03-26 | 5/250 |
|