/*注意全排列中有重複的如 aac的全排列為aacacacaa*/ #include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 100int len, flag;char str[MAX];char num[MAX];int used[MAX];void dfs( int x ){int i;if( x == len ){for( i = 0; i < len; i++
問題: c#中new和override的區別 問題補充:例如: A類 有方法 public virtual void test() B類繼承自A類,有方法 public new void test() 如下執行個體化: A a = new B(); a.test(); 會調用哪個類中的TEST方法? 答案: 如果你用override,則無論調用的是A類還是B類中的TEST(),系統都會找到它實質類的TEST(); 如果是用的New,則可以通過類型轉換調用到基類的TEST();
/*簡單的拓撲排序*/#include <stdio.h>#include <stdlib.h>#include <string.h>#define M 200int t, n, m, data[M][M];int topo[M], c[M], data[M][M];int dfs( int u ){ int v; c[u] = -1; for( v = 1; v <= n; v++ ) if( data[u][v] )
/*大水水一個*/#include <stdio.h>#include <string.h>#define MAX 1010int main(){ int N, A, B, used_s[MAX],used_g[MAX], s[MAX], g[MAX], cout = 0, i, j; while( scanf( "%d", &N ) && N ) { for( i = 1; i <= N; i++ )
//很水的題,我看時間3秒,資料10000以內,就直接冒泡排序,然後一個尋找就OK了,發現uva的水體最大難度在與題目英文超長,每次讀題都很痛苦,好吧,我只好用這個了//http://www.nocow.cn #include <stdio.h>#include <string.h>int main(){ int n, m, a[10010], b[10010], i, j, cout = 1, flag, temp; while( scanf(
#include <stdio.h>#include <math.h>#include <stdlib.h>#define MAX 200typedef struct cherry{int x, y;}C;int N;C ch[MAX];int cal( int A, int B ){int time, x, y;x = y = 0;for( time = 0; time < 2*N; time++ ){if( (ch[time].x * A + ch[
//繼續水一個大數字乘法,絕對的模板題........#include <stdio.h>#include <string.h>#define MAX_LEN 400int main(){ int i, j; int len1, len2; int a[MAX_LEN+10], b[MAX_LEN+10], c[MAX_LEN*2+10]; char str1[MAX_LEN+10], str2[MAX_LEN+10]; while(
#include <stdio.h>#include <string.h>#include <stdlib.h>int d[8][2]={{1,2},{2,1},{-1,2},{-1,-2},{1,-2},{-2,-1},{-2,1},{2,-1}};int q[100];int dis[10][10];int vis[10][10];void bfs( int x, int y ){int front, rear, nx, ny, u, i, v;u =