我的第一个程序:#include "stdafx.h" #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { std::cout << "please enter two int numbers:" << std::endl; int v1,v2; std::cin >> v1 >> v2; std::cout<<"the number " << v1 << " + " << v2 << " = " << v1+v2 << std::endl; return 0; } 我的问题:程序执行完就关闭了,如何不关闭?解答如下,看代码: #include "stdafx.h" #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { int v1=0,v2=1; while(v2<=10) { v1+=v2; ++v2; } std::cout << "1到10相加=" << v1 << std::endl; system("pause"); return 0; } 主要是在 return "0"之前 加了一个 system("pause")