Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- 2 #include <stdlib.h> //biblioteca para "system ("clear")"
- 3 #define SIZE_MATRIZ 25 //tamanho maximo de todas as matrizes
- 4 #define SIZE_VETOR 20 //tamanho maximo de todos os vetores a exce ssao dos vetores que serao intercalados
- 5 #define SIZE_VETOR_2 8 //tamanho dos dois vetores que sao intercal ados
- 6 #define SIZE_VETOR_3 16 //tamanho do Vetor Intercalado
- 7
- 8
- 9
- 10
- 11 // CODIGO DE UMA CALCULADO RA DE VETORES E MATRIZES
- 12
- 13
- 14 //FUNCOES QUE ZERAM A MATRIZ
- 15
- 16 float zeraMatriz (int tamanhoColunasPrimeiraMatriz, int tamanhoLinhasP rimeiraMatriz, int tamanhoLinhasSegundaMatriz, int tamanhoColunasSegun daMatriz)
- 17 {
- 18 float resultadoMultiplicacao [SIZE_MATRIZ][SIZE_MATRIZ];
- 19 float resultadoTransposta [SIZE_MATRIZ][SIZE_MATRIZ];
- 20 float resultadoVetorIntercalado [SIZE_VETOR];
- 21 int indiceResultadoVetorIntercalado;
- 22 int indiceColunas;
- 23 int indiceLinhas;
- 24 int indiceGeral;
- 25
- 26 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz ; indiceColunas++)
- 27 {
- 28 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 29 {
- 30 resultadoMultiplicacao[indiceLinhas][indiceColunas] = 0;
- 31 }
- 32 }
- 33
- 34 for (indiceColunas = 0; indiceColunas < tamanhoColunasSegundaMatriz; indiceColunas++)
- 35 {
- 36 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasSegundaMatriz; indiceLinhas++)
- 37 {
- 38 resultadoTransposta[indiceLinhas][indiceColunas] = 0;
- 39 }
- 40 }
- 41
- 42 return 0;
- 43 }
- 44
- 45 //FUNCOES QUE PREENCHEM TANTO VETOR QUANTO MATRIZ
- 46
- 47 float preenchePrimeiroVetor (float primeiroVetor [SIZE_VETOR], int tam anhoPrimeiroVetor)
- 48 {
- 49 int indiceGeral;
- 50
- 51 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indiceGera l++)
- 52 {
- 53 printf ("Diga os valores para completar o Primeiro Vetor:\n");
- 54 scanf ("%f",&primeiroVetor[indiceGeral]);
- 55 }
- 56
- 57 return 0;
- 58 }
- 59
- 60 float preencheSegundoVetor (float segundoVetor [SIZE_VETOR], int taman hoSegundoVetor)
- 61 {
- 62 int indiceGeral;
- 63
- 64 for (indiceGeral = 0; indiceGeral < tamanhoSegundoVetor; indiceGeral ++)
- 65 {
- 66 printf ("Diga os valores para completar o Segundo Vetor:\n");
- 67 scanf ("%f",&segundoVetor[indiceGeral]);
- 68 }
- 69
- 70 return 0;
- 71 }
- 72
- 73 float preenchePrimeiroVetorIntercalado (float primeiroVetorIntercalado [SIZE_VETOR], int tamanhoPrimeiroVetorIntercalado)
- 74 {
- 75 int indiceGeral;
- 76
- 77 do
- 78 {
- 79 for (indiceGeral = 0; indiceGeral < 8; indiceGeral++)
- 80 {
- 81 printf ("Diga os valores para completar o Primeiro Vetor que ser a Intercalado:\n");
- 82 scanf ("%f",&primeiroVetorIntercalado[indiceGeral]);
- 83 }
- 84 }while (indiceGeral != 8);
- 85
- 86 return 0;
- 87 }
- 88
- 89 float preencheSegundoVetorIntercalado (float segundoVetorIntercalado [ SIZE_VETOR], int tamanhoSegundoVetorIntercalado)
- 90 {
- 91 int indiceGeral;
- 92
- 93 do
- 94 {
- 95 for (indiceGeral = 0; indiceGeral < 8; indiceGeral++)
- 96 {
- 97 printf ("Diga os valores para completar o Segundo Vetor que sera Ordenado:\n");
- 98 scanf ("%f",&segundoVetorIntercalado[indiceGeral]);
- 99 }
- 100 } while (indiceGeral != 8);
- 101
- 102 return 0;
- 103 }
- 105 float preenchePrimeiraMatriz (float primeiraMatriz [SIZE_MATRIZ][SIZE_ MATRIZ],int tamanhoColunasPrimeiraMatriz, int tamanhoLinhasPrimeiraMat riz)
- 106 {
- 107 int indiceColunas;
- 108 int indiceLinhas;
- 109
- 110 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz ; indiceColunas++)
- 111 {
- 112 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 113 {
- 114 printf ("Diga o valor para completar a %d Linha e %d Coluna da s ua Primeira Matriz:\n", indiceColunas+1, indiceLinhas+1);
- 115 scanf ("%f",&primeiraMatriz[indiceLinhas][indiceColunas]);
- 116 }
- 117 }
- 118
- 119 return 0;
- 120
- 121 }
- 122
- 123 float preencheSegundaMatriz (float segundaMatriz [SIZE_MATRIZ][SIZE_MA TRIZ], int tamanhoColunasSegundaMatriz, int tamanhoLinhasSegundaMatriz )
- 124 {
- 125 int indiceColunas;
- 126 int indiceLinhas;
- 127
- 128 for (indiceColunas = 0; indiceColunas < tamanhoColunasSegundaMatriz; indiceColunas++)
- 129 {
- 130 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasSegundaMatriz; indiceLinhas++)
- 131 {
- 132 printf ("Diga o valor para completar a %d Linha e %d Coluna da s ua Segunda Matriz:\n", indiceLinhas + 1, indiceColunas + 1);
- 133 scanf ("%f",&segundaMatriz[indiceLinhas][indiceColunas]);
- 134 }
- }
- 136
- 137 return 0;
- 138
- 139 }
- 140
- 141 //FUNCOES QUE PRINTAM TANTO VETOR QUANTO MATRIZ
- 142
- 143 float mostraPrimeiroVetor (float primeiroVetor [SIZE_VETOR], int taman hoPrimeiroVetor, int indiceGeral)
- 144 {
- 145
- 146 printf ("\t\t\t\t\nSeu Primeiro Vetor:\n");
- 147
- 148 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indiceGera l++)
- 149 {
- 150 printf ("[%.5f]\n",primeiroVetor[indiceGeral]);
- 151 }
- 152
- 153 return 0;
- 154
- 155 }
- 156
- 157
- 158 float mostraSegundoVetor (float segundoVetor [SIZE_VETOR], int tamanho SegundoVetor, int indiceGeral)
- 159 {
- 160
- 161
- 162 printf ("\t\t\t\t\nSeu Segundo Vetor:\n");
- 163
- 164 for (indiceGeral = 0; indiceGeral < tamanhoSegundoVetor; indiceGeral ++)
- 165 {
- 166 printf ("[%.5f]\n",segundoVetor[indiceGeral]);
- 167 }
- 168
- 169 return 0;
- 170
- }
- 172
- 173 float mostraPrimeiraMatriz (float primeiraMatriz [SIZE_MATRIZ][SIZE_MA TRIZ], int tamanhoColunasPrimeiraMatriz, int tamanhoLinhasPrimeiraMatr iz)
- 174 {
- 175 int indiceColunas;
- 176 int indiceLinhas;
- 177
- 178 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz ; indiceColunas++)
- 179 {
- 180 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 181 {
- 182 printf ("\t%.5f",primeiraMatriz[indiceLinhas][indiceColunas]);
- 183 }
- 184 printf ("\n");
- 185 }
- 186
- 187 return 0;
- 188 }
- 189
- 190 float mostraSegundaMatriz (float segundaMatriz [SIZE_MATRIZ][SIZE_MATR IZ], int tamanhoColunasSegundaMatriz, int tamanhoLinhasSegundaMatriz)
- 191 {
- 192 int indiceColunas;
- 193 int indiceLinhas;
- 194
- 195 for (indiceColunas = 0; indiceColunas < tamanhoColunasSegundaMatriz; indiceColunas++)
- 196 {
- 197 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasSegundaMatriz; indiceLinhas++)
- 198 {
- 199 printf ("\t%.5f",segundaMatriz[indiceLinhas][indiceColunas]);
- 200 }
- 201 printf ("\n");
- 202 }
- 203
- 204 return 0;
- }
- 206
- 207 float mostraPrimeiroVetorIntercalado (float primeiroVetorIntercalado [ SIZE_VETOR], int tamanhoPrimeiroVetorIntercalado, int indiceGeral)
- 208 {
- 209
- 210 printf ("\t\t\t\t\nSeu Primeiro Vetor a ser Intercalado:\n");
- 211
- 212 for (indiceGeral = 0; indiceGeral < 8; indiceGeral++)
- 213 {
- 214 printf ("[%.5f]\n",primeiroVetorIntercalado[indiceGeral]);
- 215 }
- 216
- 217 return 0;
- 218 }
- 219
- 220 float mostraSegundoVetorIntercalado (float segundoVetorIntercalado [SI ZE_VETOR], int tamanhoSegundoVetorIntercalado, int indiceGeral)
- 221 {
- 222
- 223 printf ("\t\t\t\t\nSeu Segundo Vetor a ser Intercalado:\n");
- 224
- 225 for (indiceGeral = 0; indiceGeral < 8; indiceGeral++)
- 226 {
- 227 printf ("[%.5f]\n",segundoVetorIntercalado[indiceGeral]);
- 228 }
- 229
- 230 return 0;
- 231 }
- 232 //FUNCOES DE OPERACOES DO MENU
- 233
- 234 /* case 1 do Menu de Operacoes */ float somaDoisVetores (float primeir oVetor [SIZE_VETOR], float segundoVetor [SIZE_VETOR], int tamanhoPrime iroVetor, int tamanhoSegundoVetor, float resultadoSoma [SIZE_VETOR])
- 235 {
- 236 int indiceGeral;
- 237
- 238 if (tamanhoPrimeiroVetor != tamanhoSegundoVetor)
- 239 printf ("Para realizar a soma, os tamanhos devem ser iguais\n");
- 240 else
- for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indice Geral++)
- 242 {
- 243 resultadoSoma[indiceGeral] = primeiroVetor[indiceGeral] + segu ndoVetor[indiceGeral];
- 244 }
- 245
- 246 printf ("Resultado da soma dos dois Vetores:\n");
- 247 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indice Geral++)
- 248 {
- 249 printf ("[%.5f]\n",resultadoSoma[indiceGeral]);
- 250 }
- 251
- 252
- 253 return 0;
- 254 }
- 255
- 256
- 257 /* case 4 do Menu de Operacoes */ int ordenaVetorInteiros (int terceir oVetor [SIZE_VETOR], int tamanhoTerceiroVetor)
- 258 {
- 259 int indice1TerceiroVetor;
- 260 int indice2TerceiroVetor;
- 261 int auxiliarOrdenacao;
- 262
- 263 for (indice1TerceiroVetor = 0; indice1TerceiroVetor < tamanhoTerceir oVetor; indice1TerceiroVetor++)
- 264 {
- 265 for (indice2TerceiroVetor = 0; indice2TerceiroVetor < tamanhoTerce iroVetor; indice2TerceiroVetor++)
- 266 {
- 267 if (terceiroVetor[indice1TerceiroVetor] < terceiroVetor[indice2T erceiroVetor])
- 268 {
- 269 auxiliarOrdenacao = terceiroVetor[indice1TerceiroVetor];
- 270 terceiroVetor[indice1TerceiroVetor] = terceiroVetor[indice2Ter ceiroVetor];
- 271 terceiroVetor[indice2TerceiroVetor] = auxiliarOrdenacao;
- 272 }
- 273 }
- }
- 275
- 276 for (indice1TerceiroVetor = 0; indice1TerceiroVetor < tamanhoTerceir oVetor; indice1TerceiroVetor++)
- 277 {
- 278 printf ("[%d]\n", terceiroVetor[indice1TerceiroVetor]);
- 279 }
- 280
- 281 return 0;
- 282 }
- 283
- 284 /* case 6 do Menu de Operacoes*/ float multiplicacaoMatrizes (float p rimeiraMatriz[SIZE_MATRIZ][SIZE_MATRIZ], float segundaMatriz[SIZE_MATR IZ][SIZE_MATRIZ], int tamanhoColunasPrimeiraMatriz, int tamanhoLinhasP rimeiraMatriz, int tamanhoColunasSegundaMatriz, int tamanhoLinhasSegun daMatriz)
- 285 {
- 286
- 287 float resultadoMultiplicacao[SIZE_MATRIZ][SIZE_MATRIZ];
- 288 int auxiliarMultiplicacao;
- 289 int indiceColunasGeral;
- 290 int indiceLinhasGeral;
- 291 int indiceColunas;
- 292 int indiceLinhas;
- 293 int indiceGeral;
- 294
- 295 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz ; indiceColunas++)
- 296 {
- 297 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 298 {
- 299 resultadoMultiplicacao[indiceLinhas][indiceColunas] = (primeiraM atriz[indiceLinhas][indiceColunas] * segundaMatriz[indiceLinhas][indic eColunas]);
- 300 }
- 301 }
- 302
- 303 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz ; indiceColunas++)
- 304 {
- or (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 306 {
- 307 printf ("\t%.5f",resultadoMultiplicacao[indiceLinhas][indiceColu nas]);
- 308 }
- 309 printf ("\n");
- 310 }
- 311
- 312 return 0;
- 313 }
- 314
- 315 float mediaVetor (float primeiroVetor [SIZE_VETOR], float segundoVetor [SIZE_VETOR], float vetorMedia [SIZE_VETOR], int tamanhoPrimeiroVetor , int mediaTotalVetor)
- 316 {
- 317
- 318 int indice;
- 319
- 320 /* for (indice = 0; indice < tamanhoPrimeiroVetor; indice++)
- 321 {
- 322 vetorMedia[indice] = primeiroVetor[indice]/segundoVetor[indice];
- 323 }
- 324
- 325 for (indice = 0; indice < tamanhoPrimeiroVetor; indice++)
- 326 {
- 327 printf ("Media dos dois vetores:\n [%f]\n",vetorMedia[indice]);
- 328 }
- 329 */
- 330
- 331 for (indice = 0; indice < tamanhoPrimeiroVetor; indice++)
- 332 {
- 333 mediaTotalVetor = (mediaTotalVetor + primeiroVetor[indice])/tamanh oPrimeiroVetor;
- 334 }
- 335
- 336 printf ("%d",mediaTotalVetor);
- 337
- 338 return 0;
- 339
- }
- 341
- 342
- 343
- 344
- 345 //FUNCAO PRINCIPAL
- 346
- 347 int main ()
- 348 {
- 349
- 350 // variaveis de vetores e matrizes
- 351 float resultadoMultiplicacao[SIZE_MATRIZ][SIZE_MATRIZ];
- 352 float resultadoTransposta[SIZE_MATRIZ][SIZE_MATRIZ];
- 353 float segundaMatriz[SIZE_MATRIZ][SIZE_MATRIZ];
- 354 float primeiraMatriz[SIZE_MATRIZ][SIZE_MATRIZ];
- 355 float primeiroVetorIntercalado [SIZE_VETOR_2];
- 356 float resultadoVetorIntercalado[SIZE_VETOR_3];
- 357 float segundoVetorIntercalado [SIZE_VETOR_2];
- 358 int resultadoProduto[SIZE_VETOR];
- 359 float resultadoSoma [SIZE_VETOR];
- 360 float primeiroVetor[SIZE_VETOR];
- 361 int terceiroVetor[SIZE_VETOR];
- 362 float segundoVetor[SIZE_VETOR];
- 363 float vetorMedia [SIZE_VETOR];
- 364 float mediaTotalVetor = 0;
- 365 // variaveis de tamanho e indice dos Vetores e Matrizes
- 366 int tamanhoPrimeiroVetorIntercalado;
- 367 int indiceResultadoVetorIntercalado;
- 368 int tamanhoSegundoVetorIntercalado;
- 369 int tamanhoColunasPrimeiraMatriz;
- 370 int tamanhoLinhasPrimeiraMatriz;
- 371 int tamanhoColunasSegundaMatriz;
- 372 int tamanhoLinhasSegundaMatriz;
- 373 int tamanhoPrimeiroVetor;
- 374 int indice1TerceiroVetor;
- 375 int indice2TerceiroVetor;
- 376 int tamanhoTerceiroVetor;
- 377 int tamanhoSegundoVetor;
- 378 int indiceResultado;
- 379 int indiceColunas;
- int indiceLinhas;
- 381 int indiceGeral;
- 382
- 383 // outras variaveis
- 384 int resultadoFinalProduto;
- 385 int auxiliarMultiplicacao;
- 386 int auxiliarIntercalado2;
- 387 int auxiliarIntercalado;
- 388 int auxiliarPrintaFinal;
- 389 int auxiliarSaida;
- 390 int auxiliarSaida2;
- 391 int auxiliarOrdenacao;
- 392 char auxiliarExclusao;
- 393 int myBoolean2;
- 394 int myBoolean3;
- 395 int myBoolean;
- 396 int preOpcoes;
- 397 int opcoes;
- 398
- 399 // printf ("\n\tAntes de comecar, e necessario definir o tamanho dos vetores e matrizes que serao trabalhadas\n\n");
- 400 printf ("\n Calculadora de Matrizes e Vetores\n\n");
- 401
- 402 while (myBoolean == 0)
- 403 {
- 404 do
- 405 {
- 406 printf (" Menu Principal\n");
- 407 printf (" | (1)Definir tamanho e parametros do primeiro vetor |\n");
- 408 printf (" | (2)Definir tamanho e parametros do segundo vetor |\n");
- 409 printf (" | (3)Definir tamanho e parametros da primeira matriz |\n");
- 410 printf (" | (4)Definir tamanho e parametros da segunda matriz |\n");
- 411 printf (" | (5)Sair para o Menu de Operacoes |\n");
- 412 scanf ("%d",&preOpcoes);
- 413 system ("clear");
- 414 } while ((preOpcoes < 1) || (preOpcoes > 5));
- 415
- 416 switch (preOpcoes)
- 417 {
- 418 case 1:
- 419 {
- 420 printf ("\nQual o tamanho do seu Primeiro Vetor? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- scanf ("%d",&tamanhoPrimeiroVetor);
- 422
- 423 if (tamanhoPrimeiroVetor > 0)
- 424 auxiliarPrintaFinal = 0;
- 425 else
- 426 auxiliarPrintaFinal = 1;
- 427 } while ((tamanhoPrimeiroVetor < 0) || (tamanhoPrimeiroVetor > 20));
- 428
- 429
- 430 /*F*/ preenchePrimeiroVetor (primeiroVetor, tamanhoPrimeiroVetor);
- 431 /*F*/ mostraPrimeiroVetor (primeiroVetor, tamanhoPrimeiroVetor, indiceGeral);
- 432
- 433 printf ("\nAperte 'x' para apagar o seu Primeiro Vetor\n");
- 434 scanf ("%c",&auxiliarExclusao);
- 435
- 436 do
- 437 {
- 438 if (auxiliarExclusao == 'x')
- 439 {
- 440 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indiceGeral++)
- 441 {
- 442 primeiroVetor[indiceGeral] = 0;
- 443 }
- 444
- 445 system ("clear");
- 446 printf ("Seu Primeiro Vetor foi excluido da calculadora, para inserir um novo Vetor volte ao Menu Principal apertando 0\n");
- 447 }
- 448 else
- 449 printf ("Aperte 0 para voltar ao Menu Principal\n");
- 450 scanf ("%d",&auxiliarSaida);
- 451 system ("clear");
- 452
- 453 } while (auxiliarSaida != 0 && auxiliarExclusao != 'x' && myBoolean != 0);
- 454
- 455 if (auxiliarSaida == 0)
- 456 {
- 457 myBoolean = 0;
- 458 }
- 459 else;
- 460 break;
- 461
- 462 while (myBoolean == 1)
- case 2:
- 464 do
- 465 {
- 466 printf ("\nQual o tamanho do seu Segundo Vetor? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- 467 scanf ("%d",&tamanhoSegundoVetor);
- 468 } while ((tamanhoSegundoVetor < 0) || (tamanhoSegundoVetor > 20));
- 469
- 470 if (tamanhoPrimeiroVetor > 0)
- 471 auxiliarPrintaFinal = 0;
- 472 else
- 473 auxiliarPrintaFinal = 1;
- 474
- 475 /*F*/ preencheSegundoVetor (segundoVetor, tamanhoSegundoVetor);
- 476 /*F*/ mostraSegundoVetor (segundoVetor, tamanhoSegundoVetor, indiceGeral);
- 477
- 478 printf ("\nAperte 'x' para apagar o seu Segundo Vetor\n");
- 479 scanf ("%c",&auxiliarExclusao);
- 480
- 481 do
- 482 {
- 483 if (auxiliarExclusao == 'x')
- 484 {
- 485 for (indiceGeral = 0; indiceGeral < tamanhoSegundoVetor; indiceGeral++)
- 486 {
- 487 segundoVetor[indiceGeral] = 0;
- 488 }
- 489
- 490 system ("clear");
- 491 printf ("Seu Segundo Vetor foi excluido da calculadora, para inserir um novo Vetor volte ao Menu Principal apertando 0\n");
- 492 }
- 493 else
- 494 printf ("Aperte 0 para voltar ao Menu Principal\n");
- 495 scanf ("%d",&auxiliarSaida);
- 496 system ("clear");
- 497
- 498 } while (auxiliarSaida != 0 && auxiliarExclusao != 'x');
- 499
- 500 if (auxiliarSaida == 0)
- 501 {
- 502 myBoolean = 0;
- 503 }
- 504 else;
- break;
- 506
- 507 case 3:
- 508 do
- 509 {
- 510 printf ("\nQuantas linhas tem a sua Primeira Matriz? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- 511 scanf ("%d",&tamanhoLinhasPrimeiraMatriz);
- 512
- 513 printf ("\nQuantas colunas tem a sua Primeira Matriz? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- 514 scanf ("%d",&tamanhoColunasPrimeiraMatriz);
- 515 } while ((tamanhoColunasPrimeiraMatriz < 0) || (tamanhoColunasPrimeiraMatriz > 20));
- 516
- 517 /*F*/ preenchePrimeiraMatriz (primeiraMatriz, tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz);
- 518 /*F*/ mostraPrimeiraMatriz (primeiraMatriz, tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz);
- 519
- 520 printf ("\nAperte 'x' para apagar o sua Primeira Matriz\n");
- 521 scanf ("%c",&auxiliarExclusao);
- 522
- 523 do
- 524 {
- 525 if (auxiliarExclusao == 'x')
- 526 {
- 527 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz; indiceColunas++)
- 528 {
- 529 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 530 {
- 531 primeiraMatriz[indiceLinhas][indiceColunas] = 0;
- 532 }
- 533 }
- 534
- 535 system ("clear");
- 536 printf ("Sua Primeira Matriz foi excluida da calculadora, para inserir uma nova Matriz volte ao Menu Principal apertando 0\n");
- 537 }
- 538 else
- 539 printf ("Aperte 0 para voltar ao menu principal\n");
- 540 scanf ("%d",&auxiliarSaida);
- 541 system ("clear");
- 542
- 543 } while (auxiliarSaida != 0 && auxiliarExclusao != 'x');
- 544
- 545 if (auxiliarSaida == 0)
- 546 {
- myBoolean = 0;
- 548 }
- 549 else
- 550 myBoolean = 1;
- 551 break;
- 552
- 553 case 4:
- 554 do
- 555 {
- 556 printf ("\nQuantas linhas tem a sua Segunda Matriz? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- 557 scanf ("%d",&tamanhoLinhasSegundaMatriz);
- 558
- 559 printf ("\nQuantas colunas tem a sua Segunda Matriz? Respostas negativas ou maiores que 20 nao serao consideradas:\n");
- 560 scanf ("%d",&tamanhoColunasSegundaMatriz);
- 561 } while ((tamanhoColunasSegundaMatriz < 0) || (tamanhoColunasSegundaMatriz > 20));
- 562
- 563 /*F*/ preencheSegundaMatriz (segundaMatriz, tamanhoColunasSegundaMatriz, tamanhoLinhasSegundaMatriz);
- 564 /*F*/ mostraSegundaMatriz (segundaMatriz, tamanhoColunasSegundaMatriz, tamanhoLinhasSegundaMatriz);
- 565
- 566 printf ("\nAperte 'x' para excluir sua Segunda Matriz\n");
- 567 scanf ("%c",&auxiliarExclusao);
- 568
- 569 do
- 570 {
- 571 if (auxiliarExclusao == 'x')
- 572 {
- 573 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz; indiceColunas++)
- 574 {
- 575 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 576 {
- 577 primeiraMatriz[indiceLinhas][indiceColunas] = 0;
- 578 }
- 579 }
- 580
- 581 system ("clear");
- 582 printf ("Sua Segunda Matriz foi excluida da calculadora, para inserir uma nova Matriz volte ao Menu Principal apertando 0\n");
- 583 }
- 584 else
- 585 printf ("Aperte 0 para voltar ao menu principal\n");
- 586 scanf ("%d",&auxiliarSaida);
- 587 system ("clear");
- 588
- } while (auxiliarSaida != 0 && auxiliarExclusao != 'x');
- 590
- 591 if (auxiliarSaida == 0)
- 592 {
- 593 myBoolean = 0;
- 594 }
- 595
- 596 break;
- 597
- 598 case 5:
- 599 myBoolean = 1;
- 600 myBoolean2 = 0;
- 601 break;
- 602 }
- 603
- 604 while (myBoolean2 == 0 && myBoolean != 0)
- 605 {
- 606 do
- 607 {
- 608 printf (" Menu de Operacoes\n\n");
- 609 printf (" | (1)Soma de dois vetores |\n");
- 610 printf (" | (2)Media de dois vetores |\n");
- 611 // printf (" | (2)Produto interno de dois vetores |\n");
- 612 // printf (" | (3)Intercala dois vetores de 8 posicoes em um vetor de 16 |\n");
- 613 printf (" | (4)Ordenacao de um vetor de inteiros em ordem crescente |\n");
- 614 // printf (" | (5)Transposta de uma matriz |\n");
- 615 // printf (" | (6)Multiplicacao de duas matrizes |\n");
- 616 printf (" | (7)Retornar ao Menu Principal |\n");
- 617 printf (" | (8)Sair da Calculadora |\n");
- 618
- 619 printf ("\nSeu PrimeiroVetor:\n");
- 620 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indiceGeral++)
- 621 {
- 622 printf ("[%.5f]\n",primeiroVetor[indiceGeral]);
- 623 }
- 624
- 625 printf ("\nSeu Segundo Vetor:\n");
- 626 for (indiceGeral = 0; indiceGeral < tamanhoPrimeiroVetor; indiceGeral++)
- 627 {
- 628 printf ("[%.5f]\n",segundoVetor[indiceGeral]);
- 629 }
- 630
- printf ("\nSua Primeira Matriz:\n");
- 632 for (indiceColunas = 0; indiceColunas < tamanhoColunasPrimeiraMatriz; indiceColunas++)
- 633 {
- 634 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasPrimeiraMatriz; indiceLinhas++)
- 635 {
- 636 printf ("\t%.5f",primeiraMatriz[indiceLinhas][indiceColunas]);
- 637 }
- 638 printf ("\n");
- 639 }
- 640
- 641 printf ("\nSua Segunda Matriz:\n");
- 642 for (indiceColunas = 0; indiceColunas < tamanhoColunasSegundaMatriz; indiceColunas++)
- 643 {
- 644 for (indiceLinhas = 0; indiceLinhas < tamanhoLinhasSegundaMatriz; indiceLinhas++)
- 645 {
- 646 printf ("\t%.5f",segundaMatriz[indiceLinhas][indiceColunas]);
- 647 }
- 648 printf ("\n");
- 649 }
- 650
- 651 printf ("\nQual operacao voce deseja realizar?\n");
- 652 scanf ("%d",&opcoes);
- 653 system ("clear");
- 654 } while ((opcoes < 1) || (opcoes > 9));
- 655
- 656 switch (opcoes)
- 657 {
- 658 case 1:
- 659 somaDoisVetores (primeiroVetor, segundoVetor, tamanhoPrimeiroVetor, tamanhoSegundoVetor, resultadoSoma);
- 660 do
- 661 {
- 662 printf ("Aperte 0 para voltar ao menu principal\n");
- 663 scanf ("%d",&auxiliarSaida2);
- 664 system ("clear");
- 665 } while (auxiliarSaida2 != 0);
- 666
- 667 if (auxiliarSaida2 == 0)
- 668 {
- 669 myBoolean = 0;
- 670 }
- 671 else;
- 672 break;
- 674 case 2:
- 675 system ("clear");
- 676 mediaVetor (primeiroVetor, segundoVetor, vetorMedia, tamanhoPrimeiroVetor, mediaTotalVetor);
- 677 break;
- 678
- 679
- 680
- 681 /*case 2:
- 682 produtoInternoVetores (primeiroVetor, segundoVetor, tamanhoPrimeiroVetor, tamanhoSegundoVetor);
- 683 break;
- 684 case 3:
- 685 F preenchePrimeiroVetorIntercalado ( primeiroVetorIntercalado, tamanhoPrimeiroVetorIntercalado);
- 686 F mostraPrimeiroVetorIntercalado ( primeiroVetorIntercalado, tamanhoPrimeiroVetorIntercalado, indiceGeral);
- 687
- 688 F preencheSegundoVetorIntercalado ( segundoVetorIntercalado, tamanhoSegundoVetorIntercalado);
- 689 F mostraSegundoVetorIntercalado ( segundoVetorIntercalado, tamanhoSegundoVetorIntercalado, indiceGeral);
- 690
- 691 F intercalaDoisVetores (primeiroVetorIntercalado , segundoVetorIntercalado , tamanhoPrimeiroVetorIntercalado, tamanhoSegundoVetorIntercalado, in diceGeral);
- 692 do
- 693 {
- 694 printf ("Aperte 0 para voltar ao menu principal\n");
- 695 scanf ("%d",&auxiliarSaida2);
- 696 system ("clear");
- 697 } while (auxiliarSaida2 != 0);
- 698
- 699 break;*/
- 700
- 701 case 4:
- 702 printf ("Qual o tamanho do vetor que voce deseja ordenar?\n");
- 703 scanf ("%d",&tamanhoTerceiroVetor);
- 704
- 705 for (indice1TerceiroVetor = 0; indice1TerceiroVetor < tamanhoTerceiroVetor; indice1TerceiroVetor++)
- 706 {
- 707 printf ("Diga os valores para preencher o seu vetor:\n");
- 708 scanf ("%d",&terceiroVetor[indice1TerceiroVetor]);
- 709 }
- 710
- 711 /*F*/ ordenaVetorInteiros (terceiroVetor, tamanhoTerceiroVetor);
- 712
- 713 do
- {
- 715 printf ("Aperte 0 para voltar ao menu principal\n");
- 716 scanf ("%d",&auxiliarSaida2);
- 717 system ("clear");
- 718 } while (auxiliarSaida2 != 0);
- 719
- 720 break;
- 721
- 722 /*case 5:
- 723 if (tamanhoColunasPrimeiraMatriz <= 0 && tamanhoLinhasPrimeiraMatriz <= 0 && tamanhoColunasSegundaMatriz <= 0 && tamanhoLinhasSegundaMatri z <= 0)
- 724 printf ("ERRO: Para realizar a Operacao 5 e necessario definir os parametros da sua Matriz\n\n");
- 725 else
- 726 F zeraMatriz (tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz, tamanhoColunasSegundaMatriz, tamanhoLinhasSegundaMatriz);
- 727 F transpostaMatriz (primeiraMatriz, segundaMatriz, tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz, tamanhoColunasSegundaMatriz, t amanhoLinhasSegundaMatriz);
- 728
- 729 do
- 730 {
- 731 printf ("Aperte 0 para voltar ao menu principal\n");
- 732 scanf ("%d",&auxiliarSaida2);
- 733 system ("clear");
- 734 } while (auxiliarSaida2 != 0);
- 735 break;*/
- 736
- 737 case 6:
- 738 if (tamanhoColunasPrimeiraMatriz <= 0 && tamanhoLinhasPrimeiraMatriz <= 0 && tamanhoColunasSegundaMatriz <= 0 && tamanhoLinhasSegundaMatri z <= 0)
- 739 printf ("ERRO: Para realizar a Operacao 6 e necessario definir os parametros da sua Matriz\n\n");
- 740 else
- 741 /*F*/ zeraMatriz (tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz, tamanhoColunasSegundaMatriz, tamanhoLinhasSegundaMatriz);
- 742 /*F*/ multiplicacaoMatrizes (primeiraMatriz, segundaMatriz, tamanhoColunasPrimeiraMatriz, tamanhoLinhasPrimeiraMatriz, tamanhoColunasSegunda Matriz, tamanhoLinhasSegundaMatriz);
- 743
- 744 do
- 745 {
- 746 printf ("Aperte 0 para voltar ao menu principal\n");
- 747 scanf ("%d",&auxiliarSaida2);
- 748 system ("clear");
- 749 } while (auxiliarSaida2 != 0);
- 750 break;
- 751 case 7:
- myBoolean = 0;
- 753 myBoolean2 = 1;
- 754 break;
- 755 case 8:
- 756 myBoolean2 = 1;
- 757 break;
- 758 }
- 759 }
- 760 }
- 761 return 0;
- 762 }
- 763
- 764 /*AUTORIA: GABRIEL SERRA MANHAES
- 765 DRE: 116183338
- 766 MATERIA: COMPUTACAO 1
- 767 */
- 768
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement