freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c程序設(shè)計(jì)語言習(xí)題答案-在線瀏覽

2024-08-05 15:46本頁面
  

【正文】 ng s[Max],s1。 int i = 0, j 。 。//flag 是做標(biāo)記的 cins1。 for(j = 0。 j++){ if(s[j] == s1){ flag = 1。 } } if(flag == 0){ s[i] = s1。 } } for(int k = 0。 k++ ) couts[k] 。 sort(s, i)。 k i。 coutendl。 return 0。includeiostreamincludestringusing namespace std。struct stu{ string name 。 int age 。}。n){//由小到大排序 選擇排序算法; int b,c,a。 for(a = 0。a++){ c = a。 b n。 } s1 = s[a]。 s[c] = s1。 cout您要輸入多少個(gè)學(xué)生的信息:。 cinn。in 。cins[i].name。cins[i].id。cins[i].c。cins[i].age。 sort(s,n)。 in 。 } system(pause)。}3. 將一字符串字面值賦給一個(gè)字符數(shù)組,用指針操作遍歷該字符串,統(tǒng)計(jì)輸出其中元音及輔音字母的個(gè)數(shù)。const int Max = 100。 coutinput a string : 。 char c[Max]。 for( i = 0。i++) c[i] = 39。 for(i = 0。i++) c[i] = s[i] 。 p = c。 for(。\039。p++){ if(*p == 39。||*p == 39。||*p == 39。||*p ==39。||*p ==39。) n1++。 }cout原音字母個(gè)數(shù):n1\n輔音字母個(gè)數(shù):n2endl。system(pause)。}。void swap(string amp。b){ string s0。 a = b 。}int main(){ string s1 =I love you! ,s2 = me too.。\n39。 swap(s1,s2)。\n39。 system(pause)。}6.將鍵盤輸入的若干個(gè)單詞放入一個(gè)指針數(shù)組中,對它實(shí)現(xiàn)以下操作: a. 查找某個(gè)單詞; b. 修改某個(gè)單詞; c. 刪除某個(gè)單詞; d. 復(fù)制某個(gè)單詞; e. 排序這些單詞并打印輸出。const int Ms = 50。 for(i = 0。 i++) for( j = i。j++){ if(*(s[j]) *(s[j+1])){ string s1。 *(s[j]) = *(s[j+1])。 } } for(int k = 0。k++) if(*(s[k]) != ) cout*(s[k]) 。}void search(string* s[],int n){ string a。 cina。 for(。 i++) if(*(s[i]) == a) k = 1。 else cout 沒有找到這個(gè)字符串?。n。 string a。 int i = 0,k = 0。i n。 if(k == 0) cout沒有該字符串,不能修改?。n。 cout確認(rèn)要修改嗎?[Y/n]endl。 if(c == 39。 ||c == 39。) { cout輸入修改后的字符串:。 } else cout退出!endl。 string a。 int i = 0。i n。} int main(){ string* c[Ms] 。 cout要輸入的字符串的個(gè)數(shù):。 cinn。i n amp。 i Ms。 cout輸入單詞:。 c[i] = p。loop: couta . 查找某個(gè)單詞\n b . 修該某個(gè)單詞\n c . 刪除某個(gè)單詞\n q . 退出??!\n d . 排序這些單詞并打印輸出\n 請選擇!endl。 cinc0。a39。break。b39。break。c39。break。d39。break。q39。 default : cout輸入有誤?。?!\n。 } goto loop。 }第六章 練習(xí)題:1. 從鍵盤輸入10個(gè)浮點(diǎn)數(shù),編寫計(jì)算求其和及平均值的函數(shù)。const int size = 10。 for(int i = 0。 i++) sum += a[ i ]。}float average( float aa[]){ float average = sum( aa ) / size。}int main(){ float num[ size ]。 for( int i = 0。 i++ ) cin num[i]。 cout 這十個(gè)數(shù)的平均值是 average( num ) endl。}2. 采用遞歸方式,編寫將一輸入字符串逆序輸出的函數(shù)。void ff( string ss, int i){ if( i != 0 ){ cout ss[i 1]。 ff( ss, i )。 cout 輸入一字符串: endl。 int i = ()。 cout endl。 return 0。include iostreaminclude cstdlibinclude cstdarginclude cstringinclude using namespace std。 int n = 0。 va_start(marker, format)。 。 if(c == 39。) goto end。%39。 c = format[i]。 char* pc。s39。 if(pc != NULL){ for(int j = 0。 j++){ c = pc[j]。\039。 putch(c)。 } } else {//如果對于%s的實(shí)參是空串,將打印輸出(null) cout(null)endl。 } break。c39。 putch(c)。 break。d39。 char buf[32]。\039。 m = (int)strlen(buf)。 j m。 n += m。 default : putch(39。)。 c += 2。 } } else { putch(c)。 } }end: va_end(marker)。}int main(){ int n。 cout\tnendl。g39。 cout\tnendl。 cout\tnendl。039。139。 cout\tnendl。 return 0。include iostreaminclude string using namespace std。 cout 字符串 ss1 和 ss2 相加得 ss3。}void sum( float ff1, float ff2){ float ff3 = ff1 + ff2。 cout endl。 cout 整數(shù) ii1 和 ii2 相加得 ii3。}int main(){ string ss1, ss2。 cin ss1 ss2。 cout 輸入兩個(gè)整數(shù): endl。 float ff1, ff2。 cin ff1 ff2。 sum(ff1, ff2)。 system(pause)。}5. 采用函數(shù)參數(shù)缺省值機(jī)制,編寫能分別打印輸出十進(jìn)制((默認(rèn))、八進(jìn)制和十六進(jìn)制數(shù)的函數(shù)。void output( int value, int base = 10 ){ switch( base ){ case 10: cout value 十進(jìn)制是: value endl。 case 8: cout value 八進(jìn)制是: oct value endl。 case 16: cout value 十六進(jìn)制是: hex value endl。 default: cout 輸入錯(cuò)誤 endl。 cout 輸入您想打印的數(shù): endl。 cout 您是否采用默認(rèn)進(jìn)制(10)?Y / N endl。 cin j。 if( j == 39。 || j == 39。 ){ cout 輸入您的進(jìn)制,10 或者16 : endl。 output( ii, jz )。 } system(pause)。}第七章 練習(xí)題:1. 簡述Using聲明與Using指令的區(qū)別。而Using指令是將特定名字空間中的所有名字引入到一作用域內(nèi)。include iostreaminclude stringinclude mapinclude cctypeusing namespace std。 //符號表namespace Lexer { //詞法分析模塊 enum Token_value { NAME,NUMBER,END,PLUS=39。,MINUS=39。,MUL=39。,DIV=39。, PRINT=39。,ASSIGN=39。,LP=39。,RP=39。 }。 double number_value。 Token_value get_token()。 struct Syntax_error{ const char* p。}}。 double term(bool get)。 using namespace Lexer。}namespace Driver{ //驅(qū)動(dòng)模塊 int no_of_errors。 void skip()。 cinch。39。 case 39。: case 39。: case 39。: case 39。: case 39。: case 39。: case 39。: case 39。: return curr_tok=Token_value(ch)。039。139。239。339。439。539。639。739。839。939。.39。 cinnumber_value。 default: if(isalpha(ch)){ (ch)。 return curr_tok=NAME。 return curr_tok=PRINT。 double left=term(get)。) switch(curr_tok) { case PLUS: left+=term(true)。 case MINUS: left=term(true)。 default: return left。 double left=prim(get)。) switch(curr_tok){ case MUL: left*=prim(true)。 case DIV: if(double d=prim(true)){ left/=d。 } throw Error::Zero_divide()。 }}double Parser::prim(bool get){ //Parser模塊的prim實(shí)現(xiàn) using namespace Lexer。 switch(curr_tok) { case NUMBER: { double v=number_value。 return v。 v=table[string_value]。 return v。 case LP: { double e=expr(true)。 get_token()。 } case END: return 1。 }}void Driver::skip(){ //Driver模塊的skip實(shí)現(xiàn) no_of_errors++。 inputget(ch)。\n39。39。 } }}int main(int argc,char* argv[]) {
點(diǎn)擊復(fù)制文檔內(nèi)容
醫(yī)療健康相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1