第五周作業

2022-05-30 12:33:12 字數 1639 閱讀 4731

要求

回答這個作業屬於哪個課程

這個作業的要求在哪兒

在這個課程的目標

更好的鞏固字串

這個作業在哪些方面幫助我

幫助熟悉字串

參考文獻

c語言程式設計

7-1 英文單詞排序 (25 分)

本題要求編寫程式,輸入若干英文單詞,對這些單詞按長度從小到大排序後輸出。如果長度相同,按照輸入的順序不變。

輸入為若干英文單詞,每行乙個,以#作為輸入結束標誌。其中英文單詞總數不超過20個,英文單詞為長度小於10的僅由小寫英文本母組成的字串。

輸出為排序後的結果,每個單詞後面都額外輸出乙個空格。

blue

redyellow

green

purple

#

red blue green yellow purple

1)通過以自己名字命名的檔案輸入英文單詞

2)英文單詞輸入的結束標記為你學號最後一位數+37所對應的ascii字元。(例如:你的學號最後一位為9,則結束標記為9+37=46所對應的ascii字元「.」

3)在不刪除原有內容的情況下,將排序後的單詞輸出到檔案。

英文單詞排序實驗**

#include

#include

int main(void)

}for(k=0;k文字文件 

#include

#include

#include

int main()

for(i=0;i<20;i++)

for(k=0;k

temp=a[index];

a[index]=a[k];

a[k]=temp;

strcpy(t,str[index]);

strcpy(str[index],str[k]);

strcpy(str[k],t);

} for(n=0;n

for(n=0;n

if(fclose(fp))

return 0;

}3.遇到的問題即解決方案

問題一:在編寫不知道strcpy函式,導致無從下手

解決方案:上網查詢,詢問同學

問題二:對於選擇排序法這個題目理解不透徹

解決方案:去搞清楚前面學的題目

2.預習題目

周/日期

這週所花時間

**行學到知識點簡介

目前比較疑惑問題

3/22-3/29

3天90

單詞排序、指標變數初始化以及其基本運算、strcpy函式、

最大字陣列矩陣排序以及指標變數的運算與初始化的具體操作

學習感悟:主要學習了字串、單詞排序,指標變數的學習

難點:單詞排序編寫時的困難以及挑戰題中最大字數和矩陣的輸出存在很大

解決方法:主要是上網查尋以及問結對程式設計的搭檔

第五周作業

includeusing namespace std class student 用引數的初始化表對資料成員初始化。void max student arr void display private int num int score void student display void studen...

第五周作業

5求自然對數 include using namespace std int main cout e 6求圓周率 include include using namespace std int main cout pi約等於 7 include using namespace std int mai...

第五周作業

注意 總時間限制 1000ms 記憶體限制 65536kb 描述寫乙個mystring 類,使得下面程式的輸出結果是 1.abcd efgh abcd 2.abcd 3.4.abcd efgh 5.efgh 6.c 7.abcd 8.ijal 9.ijal mnop 10.qrst abcd 11....