浙大数据结构:10-排序4 统计工龄

较为简单题

1、主函数

用数组存每个数字出现了几次,再遍历一遍输出即可

cpp 复制代码
#include <iostream>
using namespace std;
#define endl '\n'

int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int a[55]={0};
  for(int i=0;i<n;i++)
  {
    int t;cin>>t;
    a[t]++;
  }
  for(int i=0;i<=50;i++)
  {
    if(a[i])cout<<i<<":"<<a[i]<<endl;
  }
  return 0;
}
相关推荐
LuminousCPP5 小时前
数据结构-双向循环链表
c语言·数据结构·笔记·链表
白狐_7986 小时前
408数据结构第5章:树与二叉树②——遍历、线索树、森林与哈夫曼
数据结构·算法·深度优先
Jasmine_llq8 小时前
《P15800 [GESP202603 六级] 选数》
数据结构·long long·逆序线性 dp·从后往前推导·转移严格遵循题意·防止总和溢出·复杂度on
疯狂打码的少年8 小时前
【数据结构】串(字符串):基本概念与存储
数据结构·笔记
纵有疾風起9 小时前
线性表的定义与基本操作 — 从逻辑结构到 ADT 接口
数据结构·算法·408·线性表·adt
wuyk55510 小时前
1.栈:后进先出的线性数据结构
c语言·数据结构·stm32·单片机
LuminousCPP11 小时前
数据结构-时间与复杂度|时间/空间复杂度 + 两道力扣练习 + 二分查找复盘
c语言·数据结构·经验分享·算法·leetcode
Nil20811 小时前
leetcode 三数之和
数据结构·算法·leetcode
noipp11 小时前
推荐题目:洛谷 P16689 出征
java·开发语言·数据结构·c++·算法·洛谷·luogu
青山木12 小时前
Hot 100 --- 最小栈
java·数据结构·算法·leetcode