C++工作笔记-map有自动排序的功能
生活随笔
收集整理的這篇文章主要介紹了
C++工作笔记-map有自动排序的功能
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
實驗如下:
代碼如下:
#include <map> #include <string> #include <iostream> #include <time.h>using namespace std;int main(){//學生信息映射分數srand((unsigned)time(NULL));map<int, string>mapStudent;for (int i = 0; i < 30; i++){int num_id = rand()%100 + 1;mapStudent.insert(pair<int, string>(num_id, "學生" + to_string(num_id)));}map<int, string>::iterator iter;for (iter = mapStudent.begin(); iter != mapStudent.end(); iter++)cout << iter->first << " " << iter->second << endl;cout << endl;getchar();return 0; }總結
以上是生活随笔為你收集整理的C++工作笔记-map有自动排序的功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux学习笔记-对父子进程直接通信基
- 下一篇: Qt工作笔记-使用QCustomplot