├── 2006 ├── Question1.c └── Question2.c ├── 2007 ├── Question1.c └── Question2.c ├── 2008 ├── Question1.c ├── Question2.c ├── Question3.c └── sample2.in ├── 2009 ├── Question1.c ├── Question2.c ├── Question3.c ├── filein.txt └── fileout.txt ├── 2010 └── Question1.c ├── 2011 ├── Question1.c ├── Question2.c ├── Question3.c ├── sample1.in └── sample2.in ├── 2012 ├── Question1.c ├── Question2.c ├── simple2.in └── simple3.in ├── 2013 ├── Question1.c ├── Question2.c ├── Question3.c ├── sample1.in └── sample3.in ├── 2014 ├── Question1.c ├── Question2.c ├── Question3.c ├── sample2.in └── sample3.in ├── 06-14上机真题及答案.doc ├── 06-14上机真题及答案.pdf ├── LICENSE └── README.MD /06-14上机真题及答案.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/06-14上机真题及答案.doc -------------------------------------------------------------------------------- /06-14上机真题及答案.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/06-14上机真题及答案.pdf -------------------------------------------------------------------------------- /2006/Question1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int cmp(const void *a , const void *b) 5 | { 6 | return *(int *)a - *(int *)b; 7 | } 8 | 9 | int set_same(int a[],int len1,int b[],int len2) 10 | { 11 | int i; 12 | qsort(a, len1, sizeof(int), cmp); 13 | qsort(b, len2, sizeof(int), cmp); 14 | 15 | if(len1 != len2) 16 | return 0; 17 | else 18 | { 19 | for(i = 0;i < len1;i++) 20 | if(a[i] != b[i]) 21 | return 0; 22 | } 23 | 24 | return 1; 25 | } 26 | 27 | int main() 28 | { 29 | int n1,n2,i; 30 | int *array1; 31 | int *array2; 32 | 33 | scanf("%d",&n1); 34 | array1 = (int *)malloc(n1 * sizeof(int)); 35 | for(i = 0;i < n1;i++) 36 | scanf("%d",&array1[i]); 37 | 38 | scanf("%d",&n2); 39 | array2 = (int *)malloc(n2 * sizeof(int)); 40 | for(i = 0;i < n2;i++) 41 | scanf("%d",&array2[i]); 42 | 43 | if(set_same(array1,n1,array2,n2)) 44 | printf("SAME\n"); 45 | else 46 | printf("NO\n"); 47 | 48 | free(array1); 49 | free(array2); 50 | return 0; 51 | } -------------------------------------------------------------------------------- /2006/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct 5 | { 6 | char name[100]; 7 | int grade; 8 | } student; 9 | student list[100]; 10 | int i = 0; 11 | 12 | int compare (const void *a, const void *b) 13 | { 14 | 15 | student *orderA = (student *)a; 16 | student *orderB = (student *)b; 17 | 18 | if ( orderB->grade != orderA->grade ) 19 | return orderB->grade - orderA->grade; 20 | else 21 | return orderB->name - orderA->name; 22 | } 23 | 24 | int main () 25 | { 26 | 27 | int n; 28 | scanf("%d",&n); 29 | for(i = 0; i < n; i++) 30 | { 31 | scanf("%s",&list[i].name); 32 | scanf("%d",&list[i].grade); 33 | } 34 | printf("AFTER sorting\n"); 35 | 36 | qsort (list, n, sizeof(student), compare); 37 | 38 | for (i = 0; i < n; i++) 39 | printf ("student name = %s grade = %d \n", list[i].name, list[i].grade); 40 | return 0; 41 | } -------------------------------------------------------------------------------- /2007/Question1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2007/Question1.c -------------------------------------------------------------------------------- /2007/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int l1, l2, i, j, k; 7 | char line1[100],line2[100],out[200]; 8 | scanf("%s",&line1); 9 | scanf("%s",&line2); 10 | 11 | l1 = strlen(line1); 12 | l2 = strlen(line2); 13 | 14 | i = 0; 15 | j = 0; 16 | k = 0; 17 | while(i < l1 || j < l2) 18 | { 19 | if(i == l1 && j < l2) 20 | { 21 | for(;j < l2;j++,k++) 22 | { 23 | out[k] = line2[j]; 24 | } 25 | } 26 | else if(i < l1 && j == l2) 27 | { 28 | for(;i < l1;i++,k++) 29 | { 30 | out[k] = line1[i]; 31 | } 32 | } 33 | 34 | if(line1[i] < line2[j]) 35 | { 36 | out[k] = line1[i]; 37 | i++; 38 | k++; 39 | } 40 | else if(line1[i] > line2[j]) 41 | { 42 | out[k] = line2[j]; 43 | j++; 44 | k++; 45 | } 46 | else 47 | { 48 | out[k] = line1[i]; 49 | i++; 50 | j++; 51 | k++; 52 | } 53 | } 54 | 55 | for(i = 0;i < k;i++) 56 | printf("%c",out[i]); 57 | printf("\n"); 58 | return 0; 59 | } -------------------------------------------------------------------------------- /2008/Question1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num, i, j, f1, f2; 6 | scanf("%d",&num); 7 | 8 | f1 = -1; 9 | for(i = 2;i < num;i++) 10 | { 11 | f2 = -1; 12 | for(j = 2; j< i;j++) 13 | { 14 | if(i % j == 0) 15 | f2 = 1; 16 | } 17 | if(f2 == -1) 18 | { 19 | f1 = 1; 20 | printf("%d ",i); 21 | } 22 | } 23 | if(f1 == -1) 24 | printf("-1\n"); 25 | else 26 | printf("\n"); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /2008/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int A[9][9], B[9][9]; 6 | int aa, ab, ba, bb, i, j, flag; 7 | 8 | freopen("sample2.in","r",stdin); 9 | 10 | scanf("%d%d",&aa,&ab); 11 | for(i = 0;i < aa;i++) 12 | for(j = 0;j < ab;j++) 13 | scanf("%d",&A[i][j]); 14 | 15 | scanf("%d%d",&ba,&bb); 16 | for(i = 0;i < ba;i++) 17 | for(j = 0;j < bb;j++) 18 | scanf("%d",&B[i][j]); 19 | 20 | flag = 1; 21 | 22 | // 0 23 | if(aa == ba && ab == bb) 24 | { 25 | for(i = 0;i < ba;i++) 26 | for(j = 0;j < bb;j++) 27 | if(A[i][j] != B[i][j]) 28 | flag = 0; 29 | if(flag == 1) 30 | { 31 | printf("0\n"); 32 | return 0; 33 | } 34 | } 35 | flag = 1; 36 | // 90 37 | if(aa == bb && ab == ba) 38 | { 39 | for(i = 0;i < aa ;i++) 40 | for(j = 0;j < ab;j++) 41 | if(A[i][j] != B[j][aa - 1 - i]) 42 | flag = 0; 43 | if(flag == 1) 44 | { 45 | printf("90\n"); 46 | return 0; 47 | } 48 | } 49 | flag = 1; 50 | // 180 51 | if(aa == ba && ab == bb) 52 | { 53 | for(i = 0;i < aa ;i++) 54 | for(j = 0;j < ab;j++) 55 | if(A[i][j] != B[aa - 1 - i][ab - 1 - j]) 56 | flag = 0; 57 | if(flag == 1) 58 | { 59 | printf("180\n"); 60 | return 0; 61 | } 62 | } 63 | flag = 1; 64 | // 270 65 | if(aa == bb && ab == ba) 66 | { 67 | for(i = 0;i < aa ;i++) 68 | for(j = 0;j < ab;j++) 69 | if(A[i][j] != B[ab - 1 - j][i]) 70 | flag = 0; 71 | if(flag == 1) 72 | { 73 | printf("270\n"); 74 | return 0; 75 | } 76 | } 77 | 78 | printf("-1\n"); 79 | return 0; 80 | } -------------------------------------------------------------------------------- /2008/Question3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAXN 1000 +10 4 | char a[MAXN][MAXN]; 5 | char s[MAXN]; 6 | 7 | int cmpch(char a, char b) 8 | { 9 | if (a >= '0' && a <= '9' && a == b) 10 | return 1; 11 | else if (a >= 'a' && a <= 'z' && (a == b || (a + 'A' - 'a') == b) ) 12 | return 1; 13 | else if (a >= 'A' && a <= 'Z' && (a == b || (a + 'a' - 'A') == b)) 14 | return 1; 15 | else 16 | return 0; 17 | } 18 | 19 | int main() 20 | { 21 | int n, i, j, m, k, mark, len; 22 | while(scanf("%d", &n) == 1) 23 | { 24 | for(i = 0; i < n; i++) 25 | scanf("%s", a[i]); 26 | scanf("%s", s); 27 | m = strlen(s); 28 | 29 | for(i = 0; i < n; i++) 30 | { 31 | len = strlen(a[i]); 32 | for(j = 0, k = 0; j < len, k < m; j++, k++) 33 | { 34 | if(cmpch(a[i][j], s[k])) 35 | continue; 36 | else 37 | { 38 | if(s[k] != '[') 39 | goto out; 40 | else 41 | { 42 | mark = 0; 43 | k = k + 1; 44 | while(s[k] != ']') 45 | { 46 | if(cmpch(a[i][j], s[k])) 47 | mark = 1; 48 | k++; 49 | } 50 | if(mark == 0) 51 | goto out; 52 | } 53 | } 54 | } 55 | out: 56 | if((j == len) && (k == m)) 57 | printf("%d %s\n", i + 1, a[i]); 58 | } 59 | } 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /2008/sample2.in: -------------------------------------------------------------------------------- 1 | 3 4 2 | 1 2 3 4 3 | 2 3 4 5 4 | 3 4 5 6 5 | 4 3 6 | 4 5 6 7 | 3 4 5 8 | 2 3 4 9 | 1 2 3 -------------------------------------------------------------------------------- /2009/Question1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | double num0 = 0, num1 = 0, num2 =0; 6 | int n, i; 7 | 8 | while(scanf("%lf%d",&num0,&n) != EOF) 9 | { 10 | i = 0; 11 | 12 | num1 = num0; 13 | while(i < n) 14 | { 15 | num2 = num1 *(2 / 3.0) + num0 / (3 * num1 *num1); 16 | num1 = num2; 17 | i++; 18 | } 19 | printf("%0.6f\n",num2); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /2009/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int cmp(const void *a , const void *b) 5 | { 6 | return *(int *)a - *(int *)b; 7 | } 8 | 9 | int main() 10 | { 11 | int n = 0, i, j, length; 12 | int* array1; 13 | int* array2; 14 | 15 | scanf("%d",&n); 16 | array1 =(int*)malloc(sizeof(int)*n); 17 | array2 =(int*)malloc(sizeof(int)*n); 18 | 19 | for(i = 0;i < n;i++) 20 | { 21 | scanf("%d",&array1[i]); 22 | array2[i] = array1[i]; 23 | } 24 | 25 | qsort(array1,n,sizeof(int),cmp); 26 | 27 | length = n; 28 | for(i = 1;i <= length;i++) 29 | { 30 | if(array1[i] == array1[i - 1]) 31 | { 32 | for(j = i;j <= length; j++) 33 | { 34 | array1[j - 1] = array1[j]; 35 | } 36 | length--; 37 | } 38 | } 39 | 40 | for(i = 0; i < n;i++) 41 | { 42 | for(j = 0;j < length;j++) 43 | { 44 | if(array1[j] == array2[i]) 45 | { 46 | printf("%d ",j+1); 47 | break; 48 | } 49 | } 50 | } 51 | printf("\n"); 52 | 53 | free(array1); 54 | free(array2); 55 | return 0; 56 | } -------------------------------------------------------------------------------- /2009/Question3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int wlength,llength,i,j,yes,tmp; 6 | char word[100]; 7 | char line[300]; 8 | scanf("%s",&word); 9 | 10 | freopen("filein.txt","r",stdin); 11 | freopen("fileout.txt","w",stdout); 12 | 13 | while(fgets(line,300,stdin)) 14 | { 15 | llength = strlen(line); 16 | 17 | while(line[0] == ' ' || line[0] == '\t' ) 18 | { 19 | for(j = 1; j < llength; j++) 20 | line[j - 1] = line[j]; 21 | llength--; 22 | } 23 | 24 | i = 0; 25 | wlength = strlen(word); 26 | tmp = -1; 27 | for(i = 0;i < llength;i++) 28 | { 29 | yes = 0; 30 | for(j = 0; j < wlength;j++) 31 | { 32 | if(i + j > llength) 33 | break; 34 | 35 | if(line[i + j] == tolower(word[j]) || line[i + j] == toupper(word[j])) 36 | yes++; 37 | else 38 | break; 39 | } 40 | 41 | if(yes == wlength) 42 | { 43 | i = i + wlength - 1; 44 | if(line[i + 1] ==' ') 45 | i++; 46 | } 47 | else 48 | { 49 | printf("%c",line[i]); 50 | } 51 | } 52 | } 53 | 54 | fclose(stdin); 55 | fclose(stdout); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /2009/filein.txt: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int printf(" Hi "); 5 | } 6 | -------------------------------------------------------------------------------- /2009/fileout.txt: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | prf(" Hi "); 5 | } 6 | -------------------------------------------------------------------------------- /2010/Question1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double pow(double num,int n) 4 | { 5 | int i; 6 | double sum = 1; 7 | for(i = 1;i <= n;i++) 8 | sum *= num; 9 | 10 | return sum; 11 | } 12 | int main() 13 | { 14 | int i, j; 15 | double input = 0,sum = 0,jie[200]; 16 | 17 | jie[1] = 1; 18 | for(i = 2;i < 200;i++) 19 | jie[i] = i * jie[i - 1]; 20 | 21 | scanf("%lf",&input); 22 | 23 | sum += 1; 24 | j = -1; 25 | for(i = 2;i < 200;i += 2) 26 | { 27 | sum += j * pow(input,i) / jie[i]; 28 | j *= -1; 29 | } 30 | 31 | printf("%f\n",sum); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /2011/Question1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2011/Question1.c -------------------------------------------------------------------------------- /2011/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int A[20][20], B[20][20]; 6 | int aa, ab, ba, bb, m, n, i, j; 7 | 8 | freopen("sample2.in","r",stdin); 9 | 10 | // Input A 11 | scanf("%d %d\n",&aa,&ab); 12 | for(i = 0;i < aa;i++) 13 | for(j = 0;j < ab;j++) 14 | scanf("%d",&A[i][j]); 15 | 16 | // Input B 17 | scanf("%d %d\n",&ba,&bb); 18 | for(i = 0; i < ba;i++) 19 | for(j = 0; j < bb;j++) 20 | scanf("%d",&B[i][j]); 21 | 22 | // Input index m n 23 | scanf("%d %d\n",&m,&n); 24 | 25 | for(i = 0; i < ba; i++) 26 | { 27 | for(j = 0; j < bb; j++) 28 | { 29 | if((i + m - 1) < aa && (j + n - 1) < ab ) 30 | A[i + m - 1][j + n - 1] = B[i][j]; 31 | } 32 | } 33 | 34 | for(i = 0; i < aa;i++) 35 | { 36 | for(j = 0; j < ab;j++) 37 | printf("%d ",A[i][j]); 38 | 39 | printf("\n"); 40 | } 41 | 42 | fclose(stdin); 43 | return 0; 44 | } -------------------------------------------------------------------------------- /2011/Question3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int i, j; 7 | char input[100],start,end; 8 | scanf("%s",input); 9 | 10 | for(i = 0;i < strlen(input);i++) 11 | { 12 | if(input[i] == '-') 13 | { 14 | start = input[i - 1]; 15 | end = input[i + 1]; 16 | 17 | if( (start >= 'a' && start <= 'z' && end >= 'a' && end <= 'z') 18 | || (start >= 'A' && start <= 'Z' && end >= 'A' && end <= 'Z') 19 | || (start >= '0' && start <= '9' && end >= '0' && end <= '9') ) 20 | for(j = start + 1;j < end;j++) 21 | printf("%c",j); 22 | else 23 | printf("-"); 24 | 25 | } 26 | else 27 | printf("%c",input[i]); 28 | } 29 | 30 | printf("\n"); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /2011/sample1.in: -------------------------------------------------------------------------------- 1 | 20 300 2 | 200 250 -------------------------------------------------------------------------------- /2011/sample2.in: -------------------------------------------------------------------------------- 1 | 3 4 2 | 10 2 34 -1 3 | 2 76 56 -200 4 | 35 0 0 98 5 | 2 3 6 | 9 9 9 7 | 9 9 9 8 | 2 3 -------------------------------------------------------------------------------- /2012/Question1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2012/Question1.c -------------------------------------------------------------------------------- /2012/Question2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, i, j, k, flag, out; 6 | int map[500][500]; 7 | //freopen("sample.txt", "r", stdin); 8 | scanf("%d", &n); 9 | memset(map, -1, 500 * 500); 10 | out = 0; 11 | for(i = 0;i < n;i++) 12 | for(j = 0;j < n;j++) 13 | scanf("%d", &map[i][j]); 14 | 15 | for(i = 0;i < n;i++) 16 | { 17 | for(j = 0;j < n;j++) 18 | { 19 | if(i == 0 || i == n - 1 || j == 0 || j == n - 1) 20 | continue; 21 | 22 | if(map[i][j] == 1) 23 | continue; 24 | 25 | flag = 0; 26 | for(k = j - 1; k >= 0; k--) 27 | { 28 | if(map[i][k] == 1) 29 | { 30 | flag++; 31 | break; 32 | } 33 | } 34 | 35 | for(k = j + 1; k < n; k++) 36 | { 37 | if(map[i][k] == 1) 38 | { 39 | flag++; 40 | break; 41 | } 42 | } 43 | 44 | for(k = i - 1; k >= 0; k--) 45 | { 46 | if(map[k][j] == 1) 47 | { 48 | flag++; 49 | break; 50 | } 51 | } 52 | 53 | for(k = i + 1; k < n; k++) 54 | { 55 | if(map[k][j] == 1) 56 | { 57 | flag++; 58 | break; 59 | } 60 | } 61 | 62 | if(flag == 4) 63 | out++; 64 | } 65 | } 66 | printf("%d\n", out); 67 | //fclose(stdin); 68 | return 0; 69 | } -------------------------------------------------------------------------------- /2012/simple2.in: -------------------------------------------------------------------------------- 1 | 6 2 | 1 1 1 1 1 1 3 | 1 1 0 0 0 1 4 | 1 0 0 0 1 0 5 | 1 1 0 1 1 1 6 | 0 1 0 1 0 0 7 | 1 1 1 1 1 1 -------------------------------------------------------------------------------- /2012/simple3.in: -------------------------------------------------------------------------------- 1 | #include int main() {int i = 0; if(i == 0) printf("YES"); return 0;} 2 | #include int main() {int ifwhile = 0; int forif = 1;char if_for_while = 'a';char *str = "while"; while(ifwhile == 0) {ifwhile = 1;forif = 0;} if(forif == 0) {if_for_while = 'b';} if(ifwhile == 1) {if_for_while = 'c';} return 0;} -------------------------------------------------------------------------------- /2013/Question1.c: -------------------------------------------------------------------------------- 1 | // Author : FinlayLiu 2 | // Time : 2015-02-26 3 | // Problem1 4 | // Debug : VC6.0 5 | 6 | #include 7 | 8 | int main() 9 | { 10 | int num1, num2, i; 11 | int yue = 0; 12 | freopen("sample1.in", "r", stdin); 13 | 14 | while(scanf("%d %d", &num1, &num2) != EOF) 15 | { 16 | for(i = num1; i >= 2; i--) 17 | { 18 | if((num1 % i == 0) && (num2 % i == 0) ) 19 | { 20 | num1 /= i; 21 | num2 /= i; 22 | } 23 | else if(num2 % num1 == 0) 24 | { 25 | num2 /= num1; 26 | num1 = 1; 27 | } 28 | } 29 | 30 | printf("%d %d\n", num1, num2); 31 | } 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /2013/Question2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2013/Question2.c -------------------------------------------------------------------------------- /2013/Question3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2013/Question3.c -------------------------------------------------------------------------------- /2013/sample1.in: -------------------------------------------------------------------------------- 1 | 2 4 2 | 2 4 3 | 10 100 4 | 45 4500 5 | 5 7 6 | 34 67 -------------------------------------------------------------------------------- /2013/sample3.in: -------------------------------------------------------------------------------- 1 | 0.2 2 | 0.000002 3 | 0.00451 4 | 123.456 5 | 123456 -------------------------------------------------------------------------------- /2014/Question1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2014/Question1.c -------------------------------------------------------------------------------- /2014/Question2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finlay-liu/BuaaMasterQuestion/d2ad2589c5d38b847c28d1ed7b77024a8935b6f8/2014/Question2.c -------------------------------------------------------------------------------- /2014/Question3.c: -------------------------------------------------------------------------------- 1 | // Question3.c 2 | // 2015-03-14 3 | #include 4 | #include 5 | #include 6 | 7 | int main() 8 | { 9 | int pos, len1, len2, i; 10 | char input[120]; 11 | char *delim = ":", *ch1, *ch2; 12 | scanf("%d\n", &pos); 13 | while(fgets(input, 100, stdin)) 14 | { 15 | ch1 = strtok(input, delim); 16 | ch2 = strtok(NULL, delim); 17 | len1 = strlen(ch1); 18 | len2 = strlen(ch2); 19 | 20 | printf("%s", ch1); 21 | for(i = 0;i < pos - len1 - 1;i++) 22 | printf(" "); 23 | printf(": %s", ch2); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /2014/sample2.in: -------------------------------------------------------------------------------- 1 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 8 | 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 9 | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 10 | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 11 | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 12 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 | 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 15 | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 16 | 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 17 | 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 18 | 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 19 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 | -------------------------------------------------------------------------------- /2014/sample3.in: -------------------------------------------------------------------------------- 1 | 10 2 | Student : Finlayerrr 3 | Work : Chotic 4 | Teacher : Pearly 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # About # 2 | 3 | 北京航天航空大学计算机研究生复试上机题目(06年-14年),题目来自网络,代码自己写。 4 | 5 | 总体来水上机题目整体不难,主要涉及的问题有: 6 | - C语言基础语法和标准库使用 7 | - 数值排序 8 | - 字符处理 9 | 10 | 有些题目我为了输入简单,使用freopen函数从文件读取测试例子。 11 | 12 | - Debug 环境: Win7 + VC6.0 (标准C语言) 13 | --------------------------------------------------------------------------------