一、最简单的C++程序。 int main() { return 0; } int :返回类型 main:函数名 ():形参列表 {。。}:函数体 二、用if语句写一个程序,来统计在输入中每个值连续出现了多少次 #include <iostream> int main() { int currVal = 0, val = 0; if (std::cin >> currVal) { int cnt = 1; while (std::cin >> val) { if (val == currVal) ++cnt; else { std::cout << currVal << " occurs " << cnt << " times" << std::endl; currVal = val; cnt = 1; } } std::cout << currVal << " occurs " << cnt << " times" << std::endl; } return 0; }