C++ 遍历set的三种方式


三种方式

                        set<int> s = mm[ques];
			for (auto it = s.cbegin(); it != s.cend(); it++)
			{
				printf("%07d\n", *it);
			}
                      set<int>* s = &mm[ques];
			for (auto it = s—>cbegin(); it != s->cend(); it++)
			{
				printf("%07d\n", *it);
			}
                        set<int>& s = mm[ques];
			for (auto it = s—>cbegin(); it != s->cend(); it++)
			{
				printf("%07d\n", *it);
			}

这个没什么注意的,但是如果需要更改记得用引用。

内置类型排序方法

按照less函数排序


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM