Skip to content

Instantly share code, notes, and snippets.

@OriLiMu
Created January 28, 2025 16:41
Show Gist options
  • Save OriLiMu/1c9ee9359c0a6427f28bc4be59d569ce to your computer and use it in GitHub Desktop.
Save OriLiMu/1c9ee9359c0a6427f28bc4be59d569ce to your computer and use it in GitHub Desktop.
get last item from vec
#include <iostream>
#include <vector>
int main() {
std::vector<int> vec = {1, 2, 3, 4, 5};
// 获取最后一个元素
int last_element = vec.back();
std::cout << "Last element: " << last_element << std::endl; // 输出 5
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment