æ¦è¦ç°¡åãªæ§ã§æå¤ã¨é£ããc++ã§ã®ã«ã¼ãå ã®vectorè¦ç´ ã®åé¤ã ã¨ããããçããç¥ãããæ¹ã¯ä¸çªä¸ã«è¡ã£ã¦ãã ããç¬ c++ã«ããã¦ãã«ã¼ãå ã§vectorããè¦ç´ ãåé¤ããå ´åãæåã«æãæµ®ãã¶å½¢åºæ¬æ¹éã¯ä»¥ä¸ã§ãã // 0 ã 4ãå ¥ã£ãvectoråå¤æ°numbersãç¨æ std::vector<int> numbers {0, 1, 2, 3, 4}; // aã¨bãé¤ããã int a = 1; int b = 3; // iteratorã§å é¨è¦ç´ ãåãã該å½å¤ã§ããã°ãã®è¦ç´ ãåé¤ for (auto itr = numbers.begin(); itr != numbers.end(); itr++) { if (((*itr) == a) || ((*itr) == b)) { numbers.erase(itr); } } ã¾ããããããäºãé å½ã«ã³ã¼ãåã
{{#tags}}- {{label}}
{{/tags}}