摘要:
去重函数。unique一般现需要对数组排序后再使用,返回值是不重复数组的哨兵位。#include #include #include using namespace std;int main(){ int a[] = {1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10}; vector vec(a, a + 16); sort(vec.begin(), vec.end()); vector::iterator pos, it; pos = unique(vec.begin(), vec.end()); for(it = vec.begin(); i 阅读全文
摘要:
原题链接#include #include using namespace std;int A[21][21];int main(){ int n, m, i, j; while(scanf("%d%d", &n, &m) == 2){ for(i = 1; i <= n; ++i) for(j = 1; j <= m; ++j){ scanf("%d", &A[i][j]); A[i][j] += max(A[i][j - 1], A[i - 1][j]); } printf("%d\n", A[ 阅读全文
摘要:
原题链接#include int A[101][101];int max(int a, int b){ if(a >= b) return a; return b;}int main(){ int n, i, j, temp; while(scanf("%d", &n) == 1){ for(i = 1; i temp) temp = A[n][j]; printf("%d\n", temp); } return 0;} 阅读全文