标签:nbsp ret log ace int tor turn name style
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int a[] = { 1,2,3,4,5,5,6,7,7,8,8,8,9,9,9,10,10 }; cout << a[0] << " "; for (int i = 1; i < 16; ++i) { if (a[i] == a[i - 1]&&a[i]==a[i+1])continue; else cout << a[i] << ‘ ‘; } system("pause"); return 0; }
通用解法2:
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int a[] = { 1,2,3,4,5,5,6,7,7,8,8,8,9,9,9,10,10 }; int n; cin >> n; for (int i = 0; i < n; ++i) cout << a[i] << ‘ ‘; for (int i = n; i < 17; ++i) { if (a[i] == a[i - n])continue; cout << a[i] << ‘ ‘; } system("pause"); return 0; }
标签:nbsp ret log ace int tor turn name style
原文地址:http://www.cnblogs.com/babyking1/p/6891187.html