CCF CSP overcome the road - 2015_03

1: image rotation (100)

1.1 Topic

Here Insert Picture Description

1.2 Code and Answers

Arrays within the main function in the open stack area (Stack); and an outer main opening function in the data area, so as to apply the array is large, the error will be placed within the main function, so that this problem can be placed outside the main function

#include<bits/stdc++.h>
#define MAXN 1005
using namespace std;
int n,m;
int db[MAXN][MAXN];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>db[i][j];
		}
	}
	for(int i=m;i>=1;i--)
	{
		for(int j=1;j<=n;j++)
		{
			cout<<db[j][i];
			if(j==n) cout<<endl;
			else cout<<" ";
		}
	}
	return 0;
}

2: Number Sequencing (100)

2.1 Topic

Here Insert Picture Description

2.2 Code and Answers

Concluding thoughts: deposit data, from small to large output

#include<bits/stdc++.h>
using namespace std;
int n;
int a[1005],b[1005]={};

int main()
{
	int max=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
		max = max > b[a[i]] ? max : b[a[i]];
	}
	for(int i=max;i>0;i--)
	{
		for(int j=1;j<1005;j++)
		{
			if(b[j]==i)
			cout<<j<<" "<<i<<endl;
		}
	}
	return 0;
}

3: festival

3.1 Topic

Here Insert Picture Description

3.2 Code and Answers




4: network latency

4.1 Topic

Here Insert Picture Description

4.2 Code and Answers




5: minimum cost

5.1 Topic

Here Insert Picture Description

5.2 Code and Answers




Published 27 original articles · won praise 6 · views 530

Guess you like

Origin blog.csdn.net/qq_43246110/article/details/104243709