所以我尝试过这个问题的不同类型的视觉基本代码,我试图解决这个问题但是没有它们正在工作:(
我有一个锯齿状数组,例如{{1 10 20 50 53};{5 15 25 55}}
并且我希望在二进制矩阵中转换此信息,条件是锯齿状数组中的每个数组对应一行,并且其中的元素对应于列号。我清楚了吗?
矩阵与锯齿状数组2中的数组数相同,但矩阵中的列可以例如直到200.
1 0 ... 1 ... 1 ... 1 .. 1..................0
0 0 ... 1 ... 1 ... 1 .... 1 ...............0
我的最后一次尝试就是这个:
For a = 0 To noRows - 1
For b = 0 To noCols - 1
Do While d < jarray(a).GetUpperBound(0)
If array(a)(d) = b Then
matrix(a, b) = 1
Exit Do
Else
matrix(a, b) = 0
d += 1
End If
Loop
Next
Next
我该怎么办?
答案 0 :(得分:0)
当你创建一个新数组时,它的值会自动初始化为数组中变量类型的默认值 - 对于一个整数,即0。所以你不需要将设置设置为零,除非有问题中未显示的其他内容。
您需要将位置的索引设置为1,因此您可以直接执行此操作:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testapp 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ testapp-server ---
[INFO] it.testapp:testapp-server:jar:0.0.1
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.12.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.5.8.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:1.5.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-actuator-docs:jar:1.5.8.RELEASE:compile
[INFO] | \- org.springframework.hateoas:spring-hateoas:jar:0.23.0.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.12.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.8.11:compile
[INFO] +- org.springframework.boot:spring-boot-starter-cache:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework:spring-context-support:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.8.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.12.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.2.11.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.1.Final:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:5.2.11.Final:compile
[INFO] | | \- net.bytebuddy:byte-buddy:jar:1.6.14:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.8.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.12.RELEASE:compile
[INFO] | | \- org.springframework:spring-tx:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-log4j2:jar:1.5.8.RELEASE:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.7:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] | +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-rest:jar:1.5.8.RELEASE:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] +- org.springframework.data:spring-data-rest-webmvc:jar:2.6.8.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-rest-core:jar:2.6.8.RELEASE:compile
[INFO] | | \- org.atteo:evo-inflector:jar:1.2.2:compile
[INFO] | +- org.springframework:spring-webmvc:jar:4.3.12.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.flywaydb:flyway-core:jar:3.2.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-freemarker:jar:1.5.8.RELEASE:compile
[INFO] | \- org.freemarker:freemarker:jar:2.3.26-incubating:compile
[INFO] +- org.springframework.boot:spring-boot-starter-hateoas:jar:1.5.8.RELEASE:compile
[INFO] | \- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:1.5.8.RELEASE:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.5.6:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mobile:jar:1.5.8.RELEASE:compile
[INFO] | \- org.springframework.mobile:spring-mobile-device:jar:1.1.5.RELEASE:compile
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.1.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:4.2.3.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-data:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.13.8.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.2.3.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.8.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile
[INFO] | | | \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile
[INFO] | \- org.springframework:spring-web:jar:4.3.12.RELEASE:compile
[INFO] +- mysql:mysql-connector-java:jar:6.0.6:runtime
[INFO] +- org.mariadb.jdbc:mariadb-java-client:jar:2.1.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.8.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.8.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.8.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | \- org.springframework:spring-test:jar:4.3.12.RELEASE:test
[INFO] +- org.springframework.security:spring-security-test:jar:4.2.3.RELEASE:test
[INFO] +- org.springframework.restdocs:spring-restdocs-mockmvc:jar:1.1.3.RELEASE:test
[INFO] | \- org.springframework.restdocs:spring-restdocs-core:jar:1.1.3.RELEASE:test
[INFO] | \- javax.servlet:javax.servlet-api:jar:3.1.0:test
[INFO] +- org.apache.commons:commons-lang3:jar:3.6:compile
[INFO] +- org.apache.commons:commons-text:jar:1.1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.4.1.Final:compile
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] +- org.hibernate:hibernate-envers:jar:5.2.11.Final:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.7.0:compile
[INFO] +- joda-time:joda-time:jar:2.9.9:compile
[INFO] +- org.springframework.data:spring-data-envers:jar:1.1.8.RELEASE:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.8.10:compile
[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.10:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.7.1-SNAPSHOT:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.14:compile
[INFO] | +- io.swagger:swagger-models:jar:1.5.14:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.7.1-SNAPSHOT:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.7.1-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.7.1-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.7.1-SNAPSHOT:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.7.1-SNAPSHOT:compile
[INFO] | | \- org.reflections:reflections:jar:0.9.11:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | \- org.mapstruct:mapstruct:jar:1.1.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.7.1-SNAPSHOT:compile
[INFO] +- io.springfox:springfox-data-rest:jar:2.7.1-SNAPSHOT:compile
[INFO] +- io.springfox:springfox-bean-validators:jar:2.7.1-SNAPSHOT:compile
[INFO] +- org.json:json:jar:20140107:compile
[INFO] +- commons-validator:commons-validator:jar:1.6:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | +- commons-digester:commons-digester:jar:2.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- org.apache.tika:tika-core:jar:1.16:compile
[INFO] +- net.sf.jasperreports:jasperreports:jar:6.4.3:compile
[INFO] | +- org.jfree:jcommon:jar:1.0.23:compile
[INFO] | +- org.jfree:jfreechart:jar:1.0.19:compile
[INFO] | +- org.eclipse.jdt.core.compiler:ecj:jar:4.4.2:compile
[INFO] | +- org.codehaus.castor:castor-xml:jar:1.3.3:compile
[INFO] | | +- org.codehaus.castor:castor-core:jar:1.3.3:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | +- stax:stax:jar:1.2.0:compile
[INFO] | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | +- org.apache.lucene:lucene-core:jar:4.5.1:compile
[INFO] | +- org.apache.lucene:lucene-analyzers-common:jar:4.5.1:compile
[INFO] | +- org.apache.lucene:lucene-queryparser:jar:4.5.1:compile
[INFO] | | +- org.apache.lucene:lucene-queries:jar:4.5.1:compile
[INFO] | | \- org.apache.lucene:lucene-sandbox:jar:4.5.1:compile
[INFO] | | \- jakarta-regexp:jakarta-regexp:jar:1.4:compile
[INFO] | +- org.olap4j:olap4j:jar:0.9.7.309-JS-3:compile
[INFO] | +- com.google.zxing:core:jar:3.2.1:compile
[INFO] | \- com.ibm.icu:icu4j:jar:57.1:compile
[INFO] +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] +- org.javers:javers-core:jar:3.6.2:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.2:compile
[INFO] | +- org.picocontainer:picocontainer:jar:2.15:compile
[INFO] | \- io.github.lukehutch:fast-classpath-scanner:jar:2.4.7:compile
[INFO] +- net.coobird:thumbnailator:jar:0.4.8:compile
[INFO] +- org.apache.pdfbox:pdfbox:jar:2.0.8:compile
[INFO] | \- org.apache.pdfbox:fontbox:jar:2.0.8:compile
[INFO] +- org.apache.pdfbox:pdfbox-tools:jar:2.0.8:compile
[INFO] | \- org.apache.pdfbox:pdfbox-debugger:jar:2.0.8:compile
[INFO] +- com.levigo.jbig2:levigo-jbig2-imageio:jar:2.0:compile
[INFO] +- com.github.jai-imageio:jai-imageio-core:jar:1.3.1:compile
[INFO] +- com.github.jai-imageio:jai-imageio-jpeg2000:jar:1.3.0:test
[INFO] +- org.apache.poi:poi:jar:3.15:compile
[INFO] | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | \- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] +- org.apache.poi:poi-scratchpad:jar:3.15:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.15:compile
[INFO] | \- com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.apache.poi:poi-ooxml-schemas:jar:3.15:compile
[INFO] +- fr.opensagres.xdocreport:org.apache.poi.xwpf.converter.core:jar:1.0.6:compile
[INFO] +- fr.opensagres.xdocreport:org.apache.poi.xwpf.converter.pdf:jar:1.0.6:compile
[INFO] +- fr.opensagres.xdocreport:fr.opensagres.xdocreport.itext.extension:jar:2.0.1:compile
[INFO] | \- com.lowagie:itext:jar:2.1.7:compile
[INFO] +- com.itextpdf:itextpdf:jar:5.5.12:compile
[INFO] +- org.apache.poi:ooxml-schemas:jar:1.3:compile
[INFO] \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] \- stax:stax-api:jar:1.0.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.334 s
[INFO] Finished at: 2017-11-20T09:47:45+01:00
[INFO] Final Memory: 31M/619M
[INFO] ------------------------------------------------------------------------
输出:
1,0,1,1,0,0,0,0,0 0,1,0,0,1,1,1,0,1