程式設計與演算法(三)第07周測驗

2022-08-27 07:06:08 字數 2461 閱讀 2876

填寫模板 printarray,使得程式輸出結果是: tomjackmaryjohn 10 不得編寫sumarray函式

#include #include using namespace std;

template t sumarray(

// 在此處補充你的**
}

int main() ;

cout << sumarray(array,array+4) << endl;

cout << sumarray(a,a+4) << endl;

return 0;

}

輸入無輸出

tomjackmaryjohn

10樣例輸入

樣例輸出

tomjackmaryjohn

10

#include #include 

using

namespace

std;

template

t sumarray(t *_start, t *_end)

return

sum;

}int

main()

; cout

<< sumarray(array,array+4)

cout << sumarray(a,a+4)

}

編寫myforeach模板,使程式按要求輸出 不得編寫 myforeach函式

#include #include using namespace std;
// 在此處補充你的**
void print(string s)

void inc(int & n)

string array[100];

int a[100];

int main()

return 0;

}

輸入多組資料

每組資料第一行是兩個整數 m 和 n ,都不超過 50

第二行是m個不帶空格的字串

第三行是 n個整數輸出對每組資料

第一行輸出所有輸入字串連在一起的結果

第二行輸出輸入中的每個整數加1的結果樣例輸入

3 4

tom mike jack

1 2 3 4

1 2peking

100 200

樣例輸出

tommikejack

2,3,4,5,

peking

101,201,

#include #include 

#include

using

namespace

std;

//在此處補充你的**

template

void myforeach(t *_start ,t*_end,void

f(t1 t ))

}void print(string

s)void inc(int &n)

string array[100

];int a[100

];int

main()

return0;

}

#include #include using namespace std;
// 在此處補充你的**
bool largerthan2(int n)

bool longerthan3(string s)

string as1[5] = ;

string as2[5];

int a1[5] = ;

int a2[5];

int main()

輸入無輸出mikejacklucy

3,4,5,樣例輸入

樣例輸出
mikejacklucy

3,4,5,

#include #include 

using

namespace

std;

//在此處補充你的**

template

t filter( t s,t e,t s2, t1 f(t2))

else ++s;

}return

s2;}

bool largerthan2(int

n)bool longerthan3(string

s)string as1[5] = ;

string as2[5

];int a1[5] = ;

int a2[5

];int

main()

程式設計與演算法(三)第2周測驗 2019夏季

程式設計填空 學生資訊處理程式 輸入輸入資料為一行,包括 姓名,年齡,學號,第一學年平均成績,第二學年平均成績,第三學年平均成績,第四學年平均成績。其中姓名為由字母和空格組成的字串 輸入保證姓名不超過20個字元,並且空格不會出現在字串兩端 年齡 學號和學年平均成績均為非負整數。資訊之間用逗號隔開。輸...

程式設計與演算法(三)第06周測驗 2020春季

輸入無輸出 d fun b fun d fun nbval 2 nbval 24 ndval 8 b fun nbval 12 樣例輸入 無樣例輸出 d fun b fun d fun nbval 2 nbval 24 ndval 8 b fun nbval 12 如下 include using ...

程式設計與演算法三七周測驗

描述 填寫模板 printarray,使得程式輸出結果是 tomjackmaryjohn 10 不得編寫sumarray函式 include include using namespace std template t sumarray 補充 int main cout sumarray array...