PTA 乙级 1064

#include<iostream>
#include<set>
using namespace std;
int f(int a){
	int sum=0;
	while(a!=0){
		sum+=a%10;
		a/=10;
	}
	return sum;
}
int main()
{	set<int> s;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		s.insert(f(x));
	}
	cout<<s.size()<<endl;
	for(auto it = s.begin();it!=s.end();it++){
		if(it!=s.begin())
		cout<<" ";
		cout<<*it;
	}
	return 0;
}

auto 在Dev中报错
但在PAT上依然AC
可加上迭代器声明通过编译
set::iterator it;

相关文章:

  • 2021-11-29
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-08-27
  • 2022-12-23
  • 2021-09-10
猜你喜欢
  • 2021-04-18
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案