C++

看板Forever_311作者 (yamap)時間16年前 (2008/03/28 15:04), 編輯推噓5(505)
留言10則, 3人參與, 最新討論串1/2 (看更多)
C++/C Computer Programming Language Middle Examination 1. (10%)Please state the features of C++ Programming Language 2. (5%) A comment is text that the compiler ignores. How to write a C++ comment to annotate code? (Hint: A C++ comment may be written in two ways) 3. (20%) (A): What is the difference between “call function by value” and “call function by reference? (B): What is the difference between regular variable and “const” variable? (C): What is the difference between local variable and global variable? (D): How the c++ limit the scope of variable? 4. (5%)What are the capabilities of the following objects? What header file should you include first if you want to use them? (Hint: #include<iostream>, #include<fstream>, #incdlue<vector>) (A): std::cout (B): std::cin (C): std::ifstream (D): std::ofstream (E): std::vector 5. (5%)Indicate the errors of the following program and correct them. #include <fstream> int main () { for (int k=0, k<10, k++) std::cout << k <<std::endl; return 0; } 6. (10%) Write the results (outputs) of the following program. #include <iostream> int main () { int a =2 , b = 3, c = 5; double x = 2.0, y = 3.0, z= 5.0; /* 6.1 */ std::cout << c/a <<std::endl; /* 6.2 */ std::cout << z/a <<std::endl; /* 6.3 */ std::cout << z/x <<std::endl; /* 6.4 */ std::cout << c%b <<std::endl; /* 6.5 */ std::cout << ((a<b) ? x : y) <<std::endl; /* 6.6 */ std::cout << a++ <<std::endl; /* 6.7 */ std::cout << ++a <<std::endl; /* 6.8 */ std::cout << ((a<b) ? x : y) <<std::endl; /* 6.9 */ for ( b = 0 ; b < 3 ; b++) std::cout << a * b << std::endl; return 0; @上機--- Finish the following three programs using a personal computer. 7. (5%) Complete the following function so that it will return the sum of all elements in the argument (std::vector<double> ) double CalSum (std::vector<double> dArg) { double sum = 0.0; for( __________________) { sum += dArg[i]; } return sum; } 8. (10%) Write a program that it writes the following data to the file “md1.dat”. The fragment must fill with your team number. The number of our team is ___ The output data 100 200 300 400 500 9. (30%) (A) Write a c++ program that can randomly generates two 5x5 matrixes and then writes these two matrix into data file “md2.dat” (B) Complete the following three functions so that it will return the sum, difference, and multiple of two matrixes, Matrix A and Matrix B. These two matrixes must be declared using std::vector< std::vector<double>>. For instance, the function definition could be as follow: std::vector<std::vector<double >> CalMatSum (std::vector<std::vector<double>> A, std::vector<std::vector<double>> B) std::vector<std::vector<double >> CalMatDiff (std::vector<std::vector<double>> A, std::vector<std::vector<double>> B) std::vector<std::vector<double >> CalMatTime (std::vector<std::vector<double>> A, std::vector<std::vector<double>> B) (C) Write a main function that i. Reads these two matrixes from md2.dat ii. Call these three functions, CalMatSum(), CalMatDiff(), CalMatTime() to calculate the sum, difference, and multiple of these two matrixes. iii. Write the produces of the main functions into md3.dat -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.168.72.167

03/28 18:12, , 1F
??你是要我們幫你翻譯嗎
03/28 18:12, 1F

03/28 21:22, , 2F
......第一題我就看不懂啦 哈哈
03/28 21:22, 2F

03/29 21:26, , 3F
我看的懂...但是不會寫
03/29 21:26, 3F

03/29 21:28, , 4F
我不知道#include iostream...等等是代表什麼意思
03/29 21:28, 4F

03/29 22:03, , 5F
#include iostream 是代表說 這個程式有用到C++內建的
03/29 22:03, 5F

03/29 22:04, , 6F
iostream 等等語言 這樣有些函數才能使用....應該啦
03/29 22:04, 6F

03/30 12:08, , 8F
希望這有幫助
03/30 12:08, 8F

03/30 14:56, , 9F
03/30 14:56, 9F

03/30 14:59, , 10F
但 我找不到我要用的函數阿
03/30 14:59, 10F
文章代碼(AID): #17x9XcJv (Forever_311)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
5
10
16年前, 03/28
2
2
16年前, 06/14
文章代碼(AID): #17x9XcJv (Forever_311)