Ir para conteúdo
Fórum Script Brasil
  • 0

Erro de sintaxe durante execução


WellFoz

Pergunta

Pessoal, sou novo na linguagem, e to com um problema.

To fazendo um pequeno projeto que, basicamente, abre um arquivo txt com varios numeros, os passa para uma matriz e depois trabalha em cima dessa matriz.

O problema é que, até compila, mas quando chega num metodo ''calcula'' está havendo algum erro de sintaxe.... por favor me ajudemmmm:

--------------------------------------------------------------------------

package TrabProj1;

public class App{

public static void main(String[] args){
Imag pict = new Imag();
Processar proc = new Processar();

pict.abreArq();
pict.lerArq();
proc.calcula(pict);
proc.inverso(pict);

}

}
[b]--------------------------------------------------------------------------[/b]
package TrabProj1;
import java.util.*;
import java.io.*;

public class Imag {
Scanner input;
Scanner in = new Scanner(System.in);
String file,file2;
private int matriz[][];
private int linha;
private int coluna;
private Formatter output;

public int getMatriz(int i, int j) {
return matriz[i][j];
}
public void setMatriz(int i, int j, int pix) {
this.matriz[i][j] = pix;
}
public int getLinha() {
return linha;
}
public void setLinha(int linha) {
this.linha = linha;
}
public int getColuna() {
return coluna;
}
public void setColuna(int coluna) {
this.coluna = coluna;
}

public void abreArq(){
try{
System.out.print("\nDigite o diretorio para abrir o arquivo: ");
file = in.nextLine();
input = new Scanner(new File (file));
}
catch (FileNotFoundException ex){
System.err.print("\nArquivo não encontrado!");
System.exit(1);
}

}
public void lerArq(){
linha = input.nextInt();
coluna = input.nextInt();
int i,j;
int matriz[][] = new int [linha][coluna];
for (i=0;i<linha;i++){
for (j=0;j<coluna;j++){
matriz[i][j] = input.nextInt();
}
}
}

public void gravArq(int cont, int id){

if (id == 256 || id == 257){
try{
file2 = in.nextLine();
output = new Formatter("inverso.txt");
if (id == 256){
output.format("%d",cont);
}
if (id == 257){
output.format("%d\n",cont);
}
}
catch (FileNotFoundException ex){
System.err.print("\nArquivo não encontrado!");
System.exit(1);
}

}
else{
try{
file2 = in.nextLine();
output = new Formatter("histograma.txt");

output.format("%d pixels %d no arquivo\n",cont,id);
}
catch (FileNotFoundException ex){
System.err.print("\nArquivo não encontrado!");
System.exit(1);
}
}
}
public void fechArq()
{
if(output!=null)
output.close();
}

}
[b]--------------------------------------------------------------------------[/b]
package TrabProj1;

public class Processar {
int cont,l,m,n,aux;

public void calcula(Imag pic){

for (l=0;l<255;l++){
for (m=0;m<pic.getLinha();m++){
for (n=0;n<pic.getColuna();n++){
if (l == pic.getMatriz(m,n)){
cont++;
}
}
System.out.printf("%d ocorrencias do pixel %d no arquivo\n",cont,l);
pic.gravArq(cont,l);
cont=0;
}
}
}
public void inverso(Imag pict){
int aux;

for (m=0;m<pict.getLinha();m++){
for (n=0;n<pict.getColuna();n++){
aux = 255 - pict.getMatriz(m, n);
pict.gravArq(aux,256);
if (m == pict.getColuna()-1){
pict.gravArq(aux,257);
}
}
}
}

}

--------------------------------------------------------------------------

não SE ASSUSTEM... ESSE É O TXT SÓ:

--------------------------------------------------------------------------

64 48

97 96 95 94 98 90 75 54 40 30 17 10 6 8 5 1 0 1 1 1 1 1 1 1 1 1 11 194 229 216 188 189 143 122 88 56 32 31 14 8 3 0 1 1 1 1 1 1 1 1 1 1 1 1 0 87 116 109 64 66 147 138 104 255

120 114 113 128 121 114 104 85 55 35 27 16 12 10 7 6 2 1 1 1 1 2 1 2 1 1 0 76 232 226 208 209 149 96 84 75 60 35 24 16 7 9 1 1 1 1 1 1 1 1 1 1 1 2 43 104 73 75 69 153 135 89 132 255

161 129 137 137 136 125 133 100 71 50 29 21 21 13 7 10 5 3 2 1 1 1 0 0 1 1 1 9 181 233 222 222 147 125 114 100 57 53 28 21 19 20 11 1 1 1 1 1 1 1 1 1 1 12 89 68 83 88 148 117 94 133 39 255

146 142 148 157 132 127 118 108 92 77 44 24 24 21 16 11 9 7 4 1 1 1 2 1 1 1 0 4 57 237 231 208 182 162 120 110 77 67 33 39 23 24 14 9 3 1 1 1 1 1 1 2 2 80 75 74 84 123 120 107 134 46 1 255

143 143 137 154 149 140 132 120 100 74 55 42 29 25 26 16 16 12 10 13 2 1 1 1 1 1 4 7 9 124 236 226 210 159 158 133 98 86 91 61 58 43 32 18 7 5 1 1 1 1 1 2 71 99 94 88 91 131 103 121 49 2 1 255

153 152 160 153 151 140 149 139 109 78 58 44 36 36 33 27 30 18 17 7 1 1 1 1 6 4 3 13 8 19 178 223 187 178 139 123 110 117 82 86 93 69 53 30 19 11 3 0 1 1 2 72 110 118 125 67 133 102 125 116 4 1 1 255

157 160 162 164 204 161 162 149 124 89 62 53 88 45 42 40 34 34 19 14 6 22 5 1 3 3 9 10 12 7 41 208 222 172 175 160 170 145 119 122 115 92 64 44 28 16 11 2 2 1 74 120 131 116 61 132 104 145 67 3 1 1 1 255

159 165 169 164 170 179 175 166 157 132 96 80 61 65 50 42 43 39 26 20 19 8 5 50 3 3 10 15 15 16 26 74 192 176 211 203 182 154 159 145 126 111 72 52 39 25 19 12 8 88 108 108 64 58 126 116 155 91 3 1 1 1 1 255

166 165 168 165 161 164 174 161 160 171 155 124 133 107 67 52 51 44 37 35 34 30 18 7 10 18 20 26 24 19 29 34 82 173 218 192 189 203 174 146 121 122 81 48 47 26 21 18 81 119 118 46 65 130 130 156 95 9 1 1 1 1 1 255

160 163 165 169 175 174 169 157 167 174 200 204 174 156 154 92 72 57 54 49 44 45 33 36 40 39 32 32 27 35 35 32 37 79 187 221 212 204 221 192 137 104 87 52 42 29 34 49 99 86 63 63 148 133 134 104 10 1 1 1 1 1 1 255

161 162 163 162 161 161 172 205 178 171 181 171 185 181 178 146 112 96 89 75 62 67 93 103 83 94 97 101 96 97 72 58 53 38 76 208 222 236 222 175 141 120 103 70 53 45 35 86 75 87 107 159 146 113 117 12 0 1 1 1 1 1 1 255

165 169 158 161 161 158 159 165 167 169 168 161 176 168 171 169 134 109 107 119 115 123 128 118 138 129 129 133 143 130 116 101 64 64 48 75 207 220 237 176 141 151 176 96 74 15 86 74 111 152 179 166 112 127 21 6 1 1 1 1 1 1 1 255

182 173 166 168 166 162 165 168 168 169 168 164 169 167 161 159 106 122 124 126 126 123 122 129 134 137 128 132 147 156 143 118 62 53 53 54 72 163 235 209 170 152 139 107 12 75 95 110 134 166 168 112 137 37 13 14 7 7 4 0 1 1 1 255

215 206 192 176 194 171 175 173 169 167 168 168 162 161 160 148 130 115 119 122 110 114 86 91 92 95 92 86 92 105 80 108 116 97 81 66 89 61 109 213 175 175 37 5 68 136 116 115 147 170 121 151 62 26 29 19 13 12 8 6 3 1 1 255

174 158 164 195 192 183 185 177 175 168 170 164 166 160 164 158 142 137 130 139 126 126 114 107 104 107 98 83 79 85 91 81 80 74 83 102 68 70 72 80 97 12 12 133 180 143 137 166 175 145 169 91 55 36 34 32 22 21 13 12 17 10 9 255

150 150 154 162 190 181 195 209 177 172 171 164 163 160 158 158 148 151 139 132 135 135 132 134 136 131 116 106 114 113 121 116 106 100 107 94 86 83 91 89 84 95 130 169 156 163 184 196 160 171 116 76 64 54 38 30 33 28 25 28 30 25 24 255

137 141 146 157 158 157 145 146 160 169 174 168 162 154 156 153 166 161 161 143 144 145 149 145 143 140 127 129 149 139 130 121 124 120 121 110 104 103 98 106 106 159 168 166 146 177 193 176 173 140 119 97 110 63 54 57 85 58 55 51 42 46 50 255

137 142 136 138 145 137 132 129 129 150 171 174 169 185 154 148 154 167 149 157 140 149 160 11 13 12 12 11 41 45 32 50 50 130 139 119 116 110 107 118 149 182 161 145 138 171 156 188 145 153 124 135 106 129 136 112 106 89 88 82 85 72 65 255

127 129 133 134 132 135 132 125 124 135 153 188 223 219 223 106 219 174 125 119 128 142 151 144 139 226 73 71 67 63 61 116 116 49 52 52 69 145 130 142 183 166 143 137 181 168 200 131 94 95 95 109 124 159 173 176 165 170 161 152 143 141 144 255

126 129 140 129 129 131 59 57 48 44 41 39 145 174 180 172 166 158 138 130 129 120 113 106 102 103 201 107 103 107 99 106 72 70 62 61 65 64 88 193 172 159 160 187 175 205 141 108 104 96 91 82 79 67 75 71 64 75 68 69 68 58 59 255

131 131 133 126 131 129 114 114 112 112 108 103 156 154 155 155 167 166 154 154 146 143 153 118 91 168 124 185 129 134 131 136 126 69 67 71 69 121 187 173 169 162 190 186 210 152 123 117 110 112 98 95 83 76 71 69 73 65 65 61 134 64 61 255

118 123 151 127 121 125 90 107 106 108 114 141 141 152 154 157 159 150 158 157 153 144 157 146 152 154 167 75 73 66 100 97 110 135 87 117 162 178 170 173 172 191 187 210 172 145 133 130 160 120 112 107 89 81 73 73 70 72 79 75 78 69 65 255

109 117 79 58 77 100 112 112 114 117 122 118 121 124 122 122 121 124 174 240 88 148 75 79 97 57 67 81 83 87 86 91 89 92 90 94 92 98 108 145 147 137 202 172 145 139 145 144 136 133 121 117 111 97 81 85 82 78 75 82 76 73 72 255

116 240 252 254 251 245 227 216 210 226 247 252 248 230 216 231 246 231 247 243 108 242 218 210 188 140 106 133 161 173 169 170 194 210 220 237 250 251 243 237 252 162 151 68 91 34 27 29 59 136 130 123 117 107 105 99 92 82 82 82 78 78 73 255

93 96 180 139 84 76 77 73 67 60 65 62 65 96 140 151 152 156 168 172 173 178 249 252 244 230 220 218 225 244 241 193 167 158 151 142 134 124 126 138 156 91 69 75 61 28 30 29 35 28 31 29 50 25 56 94 100 95 125 87 87 81 77 255

76 79 91 98 93 99 101 102 108 108 112 121 118 124 126 135 140 140 153 153 164 143 193 203 183 159 110 80 79 79 75 69 66 72 192 199 81 79 92 104 93 126 76 67 53 35 30 24 20 19 22 21 20 30 63 181 207 200 77 67 90 87 90 255

66 72 76 84 90 91 91 95 106 105 101 108 113 117 130 122 127 130 128 124 129 136 150 146 147 142 150 162 157 164 137 162 150 106 143 164 147 117 120 150 132 135 197 136 114 73 92 127 74 97 64 70 56 81 132 42 43 109 109 96 85 94 112 255

57 64 65 72 79 79 81 85 87 87 88 88 83 87 98 123 125 117 117 114 121 125 124 130 142 136 165 149 139 141 163 169 169 182 96 123 130 111 132 99 97 95 91 90 91 82 84 77 70 62 77 131 162 154 147 130 123 116 111 106 97 96 105 255

50 55 58 62 63 67 70 74 73 73 70 69 69 71 80 91 97 95 92 97 92 100 95 101 107 124 152 142 140 138 170 163 181 173 200 199 178 187 165 166 167 166 165 170 175 174 170 165 151 148 152 139 151 155 148 146 129 116 114 109 99 102 102 255

81 46 51 52 50 59 63 63 62 64 57 61 62 56 57 75 69 68 77 77 117 85 84 84 92 150 105 84 103 121 142 152 159 186 214 204 198 175 170 179 184 170 169 165 166 176 189 194 169 175 152 171 155 156 157 153 132 136 116 118 99 99 100 255

42 39 44 44 49 49 55 72 52 57 53 52 50 45 56 56 56 62 63 67 73 82 75 76 129 135 90 109 130 123 139 138 169 200 191 203 195 207 191 174 172 174 167 171 171 170 170 168 166 173 170 172 156 147 155 148 132 131 143 114 107 102 104 255

30 39 41 41 47 56 49 48 51 50 47 45 44 53 48 50 52 55 51 58 61 67 64 76 116 137 129 135 117 123 123 159 184 160 171 120 115 118 181 165 163 173 166 162 160 161 169 174 172 166 177 206 186 167 161 158 151 130 130 127 111 110 108 255

27 27 36 36 37 42 41 43 31 12 37 41 42 42 42 45 49 47 49 55 54 58 60 100 116 105 155 110 113 104 163 173 137 156 82 77 67 65 72 102 121 152 148 146 146 146 160 157 188 186 170 169 169 189 214 208 171 167 141 138 129 126 119 255

20 29 29 30 32 40 31 1 1 1 1 0 34 40 38 40 41 40 43 48 49 49 116 123 130 146 99 107 105 151 174 121 137 63 53 55 57 53 61 63 68 92 118 115 123 139 135 145 154 170 181 177 174 199 254 250 185 170 162 145 132 125 120 255

25 20 22 24 29 40 3 1 1 1 1 1 2 36 36 34 33 32 38 42 49 73 97 105 103 115 96 88 151 174 125 129 45 41 44 47 45 44 48 54 55 69 82 94 111 164 122 124 126 139 157 186 145 200 249 219 192 179 178 176 133 128 126 255

13 20 13 19 21 189 13 1 1 1 1 1 0 28 27 30 69 31 37 42 49 118 126 79 129 93 80 148 164 122 125 41 35 33 35 35 35 34 36 40 48 54 62 65 64 64 85 106 129 132 142 160 131 190 193 193 182 169 174 180 164 128 136 255

8 11 13 12 21 210 74 4 1 1 1 1 1 27 27 26 26 29 34 39 97 89 156 156 78 73 141 153 124 114 35 30 24 24 28 24 27 30 28 35 41 45 53 55 53 53 61 68 77 96 104 101 99 112 130 152 160 206 157 171 153 171 146 255

6 6 10 12 16 203 185 63 2 1 1 1 1 20 22 23 30 26 29 45 102 74 67 102 65 145 134 137 106 25 18 22 19 19 15 19 18 19 22 24 30 30 37 40 44 49 51 60 61 75 75 79 79 80 100 104 115 119 120 158 153 138 128 255

5 4 6 9 11 13 239 195 62 2 0 1 2 16 22 25 18 22 26 96 88 100 87 59 124 124 159 95 20 9 17 21 18 13 17 17 12 15 16 16 22 26 28 32 41 40 42 53 55 60 60 66 67 72 75 73 83 86 92 94 102 95 127 255

4 5 6 6 8 5 8 224 198 141 73 15 13 14 23 23 20 21 46 124 57 51 72 113 108 168 79 9 5 8 9 20 8 10 13 7 9 10 10 10 17 24 24 28 30 32 36 43 45 47 53 53 56 54 56 57 65 67 74 79 74 61 62 255

4 3 4 4 4 3 1 3 2 5 4 6 9 10 13 15 50 21 97 127 62 130 114 95 163 58 7 5 5 16 6 5 5 3 5 7 5 4 4 8 11 13 16 23 28 27 32 35 34 39 43 45 42 41 45 56 55 55 60 60 59 52 53 255

54 2 4 3 2 1 2 1 3 1 3 2 6 9 17 10 7 38 109 137 113 136 88 158 45 5 3 2 3 4 3 1 0 4 2 8 3 2 4 5 5 9 12 20 19 27 27 29 33 40 37 41 40 38 37 42 46 49 52 50 47 48 49 255

2 1 3 3 1 1 0 1 3 1 0 8 6 7 7 6 16 99 124 122 125 88 139 34 3 1 1 0 8 61 1 1 1 1 0 1 1 1 1 1 4 5 8 12 22 21 25 28 33 35 34 33 32 36 37 36 35 38 42 41 38 43 40 255

1 1 0 1 2 1 0 0 6 1 2 3 4 10 6 5 40 86 114 93 124 123 24 2 1 1 1 2 2 0 1 1 1 1 1 1 1 1 1 1 1 6 5 9 15 18 22 23 23 29 27 31 35 31 40 37 36 36 34 36 49 35 36 255

1 1 1 1 0 1 3 1 0 1 1 1 1 2 1 5 142 91 84 176 89 10 1 1 5 1 1 1 1 1 1 1 1 2 0 2 1 1 1 1 2 3 5 10 14 22 20 19 22 20 21 26 26 30 30 32 24 35 36 38 38 36 35 255

1 0 1 1 1 0 1 23 1 1 0 2 1 1 1 14 159 186 140 42 1 1 1 0 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 2 3 6 9 14 14 15 11 8 14 13 19 25 32 26 25 27 32 34 36 42 32 255

1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 13 86 68 8 0 1 1 1 1 51 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 6 5 5 8 8 10 4 5 6 9 11 14 24 23 19 23 24 29 29 33 30 255

1 4 3 1 1 0 4 0 1 1 3 1 4 1 1 1 4 1 1 1 1 1 2 10 0 1 0 1 1 1 0 1 1 1 1 1 10 1 1 1 1 1 5 6 3 4 4 4 2 5 1 3 3 5 12 14 19 13 19 25 28 32 28 255

Editado por quintelab
Removido Caixa Alta do título e Adicionado BBCode Code
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...