ccf

试题编号: 201503-1
试题名称: 图像旋转

#include<iostream>
using namespace std;
int main()
{
	static int a[1000][1000];//不加static也可以欸~~~
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	for(int i=m-1;i>=0;i--)
	{
		for(int j=0;j<n;j++)
			cout<<a[j][i]<<" ";	
		cout<<endl;	
	}	 
	return 0;
}

试题编号: 201503-2
试题名称: 数字排序
#include<iostream>
#include<algorithm>
using namespace std;
struct num
{
<span style="white-space:pre">	</span>int val;
<span style="white-space:pre">	</span>int time;
}a[1005];


bool cmp(num x,num y)
{
<span style="white-space:pre">	</span>if(x.time!=y.time)
<span style="white-space:pre">	</span>return x.time>y.time; 
<span style="white-space:pre">	</span>else
<span style="white-space:pre">	</span>return x.val<y.val;
<pre name="code" class="cpp">//<span>	</span>return x.time>y.time||(x.time=y.time&&x.val<y.val); 不可以
 
  
}


int main()
{
<span style="white-space:pre">	</span>int n;
<span style="white-space:pre">	</span>cin>>n;
<span style="white-space:pre">	</span>for(int i=0;i<1005;i++)//初始化不能初始为n;
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>a[i].val=i;
<span style="white-space:pre">		</span>a[i].time=0;
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>for(int i=0;i<n;i++)
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>int tmp;
<span style="white-space:pre">		</span>cin>>tmp;
<span style="white-space:pre">		</span>a[tmp].time++;
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>sort(a,a+1005,cmp);
<span style="white-space:pre">	</span>for(int i=0;i<n;i++)
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>if(a[i].time==0) break;
<span style="white-space:pre">		</span>cout<<a[i].val<<" "<<a[i].time<<endl;
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>return 0;
}
<table class="probtable " align="center" width="100%" cellpadding="0" cellspacing="1" style="margin: 0px; padding: 0px; color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; text-align: center; background: rgb(192, 214, 221);"><tbody style="margin: 0px; padding: 0px;"><tr style="margin: 0px; padding: 0px;"><td class="probref" style="margin: 0px; padding: 12px; width: 100px; vertical-align: middle; color: rgb(0, 87, 164); background: rgb(248, 248, 248);">试题编号:</td><td style="margin: 0px; padding: 12px; text-align: left; background: rgb(255, 255, 255);">201412-1</td></tr><tr style="margin: 0px; padding: 0px;"><td class="probref" style="margin: 0px; padding: 12px; width: 100px; vertical-align: middle; color: rgb(0, 87, 164); background: rgb(248, 248, 248);">试题名称:</td><td style="margin: 0px; padding: 12px; text-align: left; background: rgb(255, 255, 255);">门禁系统</td></tr></tbody></table><pre name="code" class="cpp">#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n,x;
	cin>>n;
	static int arr[1005];
	for(int i=0;i<n;i++)
	{
		cin>>x;
		arr[x]++;
		cout<<arr[x]<<" ";
	}
	return 0;
}

试题编号: 201412-2
试题名称: Z字形扫描

 
 

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int arr[505][505];
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>arr[i][j];
	int x,y;
	x=0;y=0;
	int i=0;
	while(!(x==n-1&&y==n-1))
	{
		//i++;
		cout<<arr[x][y]<<" ";
		if((x==0&&y!=(n-1)&&(y%2==0))||(x==(n-1)&&(y%2==n%2)))
		{
			y++;
		}
		else if((y==0&&x!=(n-1)&&(x%2==1))||(y==(n-1)&&(x%2!=n%2)))
		{
			x++;
		}
		else if((x+y)%2==1)
		{
			x++;y--;
		}
		else if((x+y)%2==0)
		{
			x--;y++;
		}
	}
	cout<<arr[x][y]<<" ";
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值