武汉大学遥感信息工程学院复试机试
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
2004:
#include
#include
#include
//sort所需头文件
#include
using namespace std;
int main()
{
ifstream infile("test.txt");
ofstream outfile("result.txt");
if(!infile)
{
cout<<"text.txt open failed"< return 1; } if(!outfile) { cout<<"result.txt open failed"< } vector //读出数的个数 int sum = 0; infile>>sum; int i = 0; while(i { int number = 0; infile>>number; m_vecInt.push_back(number); i++; } //排序算法 sort(m_vecInt.begin(), m_vecInt.end()); outfile<<"the min number is:"< outfile<<"the max number is:"< int mid = (sum-1)/2; outfile<<"the middle number is:"< outfile.close(); infile.close(); return 0; } 2005: #include #include #include using namespace std; typedef vector VecInt ConvolutionFun1(const vector int main() { const int M =125; const int N =80; const int R =100; const int S =100; VecInt vecInt; int i,j; ifstream infile("SourceData.txt"); if(!infile) { cout<<"SourceData.txt open failed.\n"; return 1; } vector int numeric(0); for(i=0;i<10000;i++) { infile>>numeric; vec_int.push_back(numeric); } ofstream outfile("result.txt"); if(!outfile) { cout<<"result.txt open failed.\n"; return 1; } outfile<<"卷积一次后的矩阵:\n"; vecInt = ConvolutionFun1(vec_int, M, N); for(i=0; i { for(j=0; j { outfile< } outfile<<'\n'; } outfile<<'\n'; vecInt = ConvolutionFun2(vec_int, R, S); outfile<<"第二次卷积后的矩阵:\n"; for(i=0; i { for(j=0; j { outfile< } outfile<<'\n'; } outfile<<'\n'; outfile.close(); infile.close(); return 0; } //卷积函数1 VecInt ConvolutionFun1(const vector { VecInt vecInt(m, vector int num =0; for(int i=0; i { for(int j=0; j { vecInt[i][j] = vec[num]; num++; } } int a[]={0,-1,0,-1,5,-1,0,-1,0}; for(int i=1;i { for(int j=1;j { vecInt[i][j] = vecInt[i-1][j-1] * a[0] + vecInt[i-1][j] * a[1] + vecInt[i-1][j+1]* a[2] + vecInt[i][j-1] * a[3] + vecInt[i][j] * a[4] + vecInt[i][j+1] * a[5] + vecInt[i+1][j-1] * a[6] + vecInt[i+1][j] * a[7] + vecInt[i+1][j+1] * a[8]; } } return vecInt; } //卷积函数 VecInt ConvolutionFun2(const vector {