Results 1 to 14 of 14
Thread: Java
Hybrid View
-
12th December 2008 12:23 #1
-
12th December 2008 12:46 #2Registered User
Join Date: Apr:2004
Location: EU
Posts: 141
:
if (A[i][k] && !used[k])
-
12th December 2008 12:50 #3
-
12th December 2008 14:30 #4Registered User
Join Date: Apr:2004
Location: EU
Posts: 141
icaci, ! A boolean.
used.
-
12th December 2008 18:21 #5
( =++ ; )
:Code:#include <stdio.h> /* */ #define MAXN 200 /* */ const unsigned n = 14; /* v */ const unsigned v = 5; /* */ const char A[MAXN][MAXN] = { {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0} }; char used[MAXN]; /* */ void DFS(unsigned i) { unsigned k; used[i] = 1; printf("%u ", i+1); for (k = 0; k < n; k++) if (A[i][k] && !used[k]) DFS(k); } int main(void) { unsigned k; for (k = 1; k < n; k++) used[k] = 0; printf(" %u: \n", v); DFS(v-1); printf("\n"); return 0; }
Code:public class DFS { // public static int n=14; // v public static int v=5; // public static char[][] matrix = { {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0} }; // public static char mask[] = new char[14]; // public static void DFS(int i){ int k; mask[i]=1; System.out.printf("%d ",i+1); for(k=0;k<n;k++) { if((matrix[i][k]) && (!mask[k])) DFS(k); } } public static void main(String[] args) { for(int k=1;k<n;k++) mask[k]=0; System.out.printf(" %d %n",v); DFS(v-1); System.out.println(); } }
-
12th December 2008 18:38 #6Registered User
Join Date: Apr:2004
Location: EU
Posts: 141
:
Code:if((matrix[i][k]!=0) && (mask[k]==0))
-
12th December 2008 18:44 #7
-
12th December 2008 18:53 #8Registered User
Join Date: Apr:2004
Location: EU
Posts: 141
unsigned C++ e unsigned int.
Java unsigned .
- int short.
-
12th December 2008 18:56 #9
-
12th December 2008 21:11 #10
unsigned xxx, xxx char, short, int, long long long , , . 0 (2^n)-1, n , C .
A , . used . C int ( char, ). int boolean A used, 0 false, 1 true . if (...) , C .Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
12th December 2008 22:19 #11
-
12th December 2008 23:13 #12
"Replace in selection"? - 20
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
12th December 2008 23:46 #13
-
15th December 2008 01:34 #14
Join Date: Sep:2005
Location: Sofia
Posts: 18,517
Java char . -
public static final char n = 14;




Reply With Quote
.

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in