Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. char Menu(char NomeArquivo[])
  6. {
  7. printf("Insira o nome do arquivo: ");
  8. scanf("%s", NomeArquivo);
  9. system("cls");
  10. fflush(stdin);
  11.  
  12. return* NomeArquivo;
  13. }
  14. void verificar_arquivo(char NomeArquivo[], float *juros, int *linhas, int *colunas){
  15. FILE *entrada;
  16. char teste;
  17. int linhas_arquivo = 0;
  18. int total_colunas;
  19. int verificar_linhas, verificar_colunas;
  20. entrada = fopen(NomeArquivo, "r");
  21. if (entrada== NULL)
  22. {
  23. printf("Arquivo nao existe.\n");
  24. exit(0);
  25. }
  26. while ((teste = fgetc(entrada)) != EOF){
  27. if (teste == '\n'){
  28. linhas_arquivo++;
  29. }
  30. }
  31. if (linhas_arquivo % 2 == 0){
  32. printf("Linhas insuficientes.\n");
  33. exit(0);
  34. }
  35. rewind(entrada);
  36. fscanf(entrada, "%f\n", juros);
  37. fscanf(entrada, "%d\n", linhas);
  38. fscanf(entrada, "%d\n", colunas);
  39. verificar_colunas = *colunas;
  40. verificar_linhas = *linhas;
  41. if (total_colunas != (verificar_linhas * verificar_colunas + (verificar_colunas - 1) * verificar_linhas)){ //Verifica se o arquivo possui a quantidade de colunas necessárias
  42. printf("Dados insuficientes.\n");
  43. exit(0);
  44. }
  45. }
  46. void preencher_matriz(int linhas, int colunas, float montante[50][50]){
  47. }
  48. int calculos()
  49. {
  50. }
  51.  
  52. int main()
  53. {
  54. char NomeArquivo[50];
  55. float juros;
  56. int linhas, colunas;
  57. Menu(NomeArquivo);
  58. verificar_arquivo(NomeArquivo, &juros, &linhas, &colunas);
  59. float montante[50][50];
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement