标签:定义 turn ges int include http style 技术 ++
实现代码如下:
#include<cstdlib> #include <string> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int *a = (int *)malloc(n * sizeof(n)); for (int i = 0; i < n; i++) cin >> a[i]; //定义m次操作 for (int x = 0; x < m; x++) { int t1, t2; string s; cin >> s; if (s == "DEL") { cin >> t1; for (int i = 0; i < n; i++) { if (a[i] == t1) { for (int j = i; j < n - 1; j++) a[j] = a[j + 1]; break; } } n--; } else if (s == "ADD") { n++; cin >> t1 >> t2; for (int i = 0; i < n-1; i++) { if (a[i] == t1) { for (int j = n - 1; j > i; j--) a[j] = a[j - 1]; a[i] = t2; break; } } } } cout << n << endl; for (int i = 0; i < n; i++) cout << a[i] << " "; system("PAUSE"); return 0; }
标签:定义 turn ges int include http style 技术 ++
原文地址:http://www.cnblogs.com/gmy-bstwrld/p/6885238.html