Discuz! Board

 找回密码
 立即注册
查看: 369|回复: 0

桶循环

[复制链接]

27

主题

29

帖子

1万

积分

论坛元老

Rank: 8Rank: 8

积分
14147
发表于 2022-11-26 14:33:30 | 显示全部楼层 |阅读模式
[C++] 纯文本查看 复制代码
#include<bits/stdc++.h>
using namespace std;
int t[10];
int main()
{
	int x;
	for(int i=1;i<=10;i++)
	{
		cin>>x;
		t[x]++;
		
	}
	for(int i=0;i<=9;i++)
	{
		for(int j=1;j<=t[i];j++)
		{
			cout<<i<<" ";
		}
	} 
	return 0;
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-2-13 05:31 , Processed in 0.048150 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计

快速回复 返回顶部 返回列表