//listBatchDelete范围删除 boollistBatchDelete(SqList &sql, int s, int t){ if (s > t || sql.length == 0 || t < sql.elem[0] || s > sql.elem[sql.length - 1]) { returnfalse; }
int p = 0, q = 0; while (sql.elem[p] < s) p++; cout << p; while (sql.elem[q] <= t && q <= sql.length - 1) q++; cout << q;//注意需要特判,for循环写法无需 while (q <= sql.length) { sql.elem[p] = sql.elem[q]; p++; q++; } sql.length = sql.length - (q - p);