CCF刷题-0726

201503-1
设置了矩阵数组int a[1005][1005],在dev c++上运行会报错,因为数组太大了,但没想到提交直接满分过了。
懒得想高效,占内存少的解法了…

int main() {
    cin>>n>>m;
	int a[1000][1000];
	
	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<stdlib.h>
#include<string.h> 
#include <bits/stdc++.h>
#include "sstream"
using namespace std;

#define N 1005
int n,m;

struct node {
    int x;
    int num;
};
node edge[1005];

int cmpfunc (const void * a, const void * b)
{
    struct node *c = (node *)a; 
	struct node *d = (node *)b; 
	if(c->num != d->num) return d->num - c->num; 
	else return c->x - d->x; 
}

int main() {
    cin>>n;
    int a[1005];
    int x;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
    	cin>>x;
    	a[x]++;
    	edge[x].num=a[x];
    	edge[x].x=x;
	}
	qsort(edge,1005,sizeof(edge[0]),cmpfunc);
	for(int i=0;i<n&&edge[i].num;i++){
		cout<<edge[i].x<<' '<<edge[i].num<<endl;
	}
    return 0;
}
//

今天偷懒去游泳happy了
不想面对日后参与项目的打工生活QAQ

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值