2014北郵計算機學院上午上機複試題目

2021-10-23 06:08:29 字數 3507 閱讀 1143

輸入格式

輸入資料第一行是乙個整數t(1≤t≤100),表示測試資料的組數。對於每組測試資料:

第一行是乙個正整數n(1≤n≤100),表示數列長度。

第二行有n個整數,整數之間用空格隔開,所有的整數都不超過105,表示這個數列。

輸出格式

對於每組測試資料,輸出乙個整數。

輸入樣例

541

1125

1122

3612

3456

9111

1222

24101

2223

3344

4

**:

# include

# include

# include

using

namespace std;

intmain()

int num=a[0]

;int count=1;

int maxexist=1;

int res=a[0]

;for

(int i=

1;i)else

if(maxexist} cout<}}

使用map

# include

# include

# include

# include

using

namespace std;/*5

41 1 1 2

51 1 2 2 3

61 2 3 4 5 6

91 1 1 1 2 2 2 2 4

101 2 2 2 3 3 3 4 4 4

*/int

main()

map<

int,

int>

::iterator it;

int res=0;

int count=0;

for(it=m.

begin()

;it!=m.

end(

);it++)}

cout<}return0;

}

輸入格式

輸入的第行是乙個整數t (t≤50),表示輸入的資料組數。

每組測試資料的第一.行是兩個整數n和m(1≤n,m≤50),表示的高度和寬度。

接下來n行,每行是乙個長度為m的01串,表示的畫素點。最後一行是乙個整數angle,表示旋轉的角度。

輸出格式

對於每組測試資料,輸出旋轉後得到的。請注意不要輸出多餘的空格或空行。

思路:1、旋轉90度之和的影象與原來的影象的下標有什麼關係2、順時針旋轉270度就相當於順時針旋轉90度三次;

3、注意每次旋轉之後行列的變化。

# include

# include

# include

using

namespace std;

const

int maxn=50;

int a[maxn]

[maxn]

,b[maxn]

[maxn]

;//旋轉

void

rotate

(int n,

int m,

int a[

][maxn]

,int b[

][maxn]

)//cout<}

}//輸出

void

print

(int n,

int m,

int b[

][maxn]

) cout

}int x;

cin>>x;

x=x/90;

if(x==0)

else

if(x==1)

else

if(x==2)

else

}return0;

}

這個大佬的題目鏈結**

網路的核

採用flyod演算法,解決的全源最短路徑問題(給定圖g(v,e),求任意倆點u,v之間的最短路徑長度。時間複雜度為o(n^3)。所有採用這個演算法一般頂點數限制再200以內,而且用鄰接矩陣的方法是非常合適而且非常方便的。

思想:如果存在頂點k,使得以頂點k作中介點時候頂點i和頂點j的當前最短距離縮短,則使用頂點k作為頂點i和頂點j的中介點。dis[i][k]!=inf&&dis[k][j]!=inf&&dis[i][k]+dis[k][j]# include

# include

# include

using

namespace std;

const

int inf=int_max;

const

int maxn=51;

int dis[maxn]

[maxn]

;int n;

void

floyd()

}}}int

main()

dis[i]

[i]=0;

}for

(int i=

0; i)floyd()

;/*for(int i=1;i<=n;i++)

//cout(min>res)

} cout<}return0;

}第二種方法:

# include

# include

# include

# include

# include

using

namespace std;

const

int maxv=

1000

;const

int inf=int_max;

struct edge };

struct point

bool

operator

<

(const point& p)

const};

int dis[maxv]

;vector graph[maxv]

;//graph[0]~graph[maxv-1]每乙個都是乙個vector

int n,m;

//初始化

void

initial()

//模板

void

disjkstra

(int s)}}

return;}

intmain()

// for(int i=1; i<=n; i++)

int minvalue=inf;

//最小距離之和

int min;

//最小距離之和的下標

for(

int i=

1; i<=n; i++

)//cout(minvalue>res)

} cout<}return0;

}

2014北郵計算機考研複試上機題解(上午 下午)

據江湖傳聞,2014年計算機機試分為了上午 下午兩批。先來看上午的題目。直接統計就可以。ac include includeusing namespace std int a 105 int main cnt 1 else cnt if cnt ans 最後乙個數還沒推斷 解題思路 我們能夠簡化思路...

2014北郵計算機院複試上機(上)

problem.a 眾數 思路 常規題穩拿分 include include using namespace std define maxn 100001 int cnt maxn int main else if max cnt num if num prob num num cout retur...

北郵oj 彙編 計算機二2014

這道題我開始寫了亂七八糟將近200行的 思路混亂不說,沒有ac而且錯誤極其難找,後來參考了大神的 才明白自己真的是將簡單問題複雜化了。管他什麼高位低位,只用乙個陣列表示暫存器存的數就行了,高位低位通過取餘操作就行了,無論二進位制十六進製制統統轉換為十進位制存至陣列中。include includeu...