Исправил третье задание, теперь максимум высчитывается верно
This commit is contained in:
parent
f677c28eb4
commit
d32450977c
5 changed files with 45 additions and 1 deletions
BIN
45Ex/a.exe
Normal file
BIN
45Ex/a.exe
Normal file
Binary file not shown.
13
46Ex/main.c
Normal file
13
46Ex/main.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include "tools.h"
|
||||
|
||||
int solutionPolynomial(FILE * file, double x, double * &derivative, double * &polynomial)
|
||||
|
||||
int main(void) {
|
||||
double x, derivative, polynomial;
|
||||
FILE * file = getFile();
|
||||
if (file == NULL) return 1;
|
||||
|
||||
printf("Enter the x cordinate: ");
|
||||
scanf("%lf", &x);
|
||||
}
|
23
46Ex/tools.c
Normal file
23
46Ex/tools.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "tools.h"
|
||||
|
||||
FILE * getFile(void)
|
||||
{
|
||||
FILE * file;
|
||||
char filename[50];
|
||||
|
||||
printf("Enter filename: ");
|
||||
if (scanf("%s", filename) == 1)
|
||||
{
|
||||
file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
printf("Error file!\n");
|
||||
return NULL;
|
||||
} else {
|
||||
return file;
|
||||
}
|
||||
} else
|
||||
{
|
||||
printf("Empty name!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
8
46Ex/tools.h
Normal file
8
46Ex/tools.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef TOOLS
|
||||
#define TOOLS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
FILE * getFile(void);
|
||||
|
||||
#endif
|
|
@ -21,7 +21,7 @@ int getCountMaxLocal(FILE *file) {
|
|||
|
||||
while (fscanf(file, "%d", ¤t_n) == 1) {
|
||||
if (last == current_n) {
|
||||
length += 1;
|
||||
if (length) length++;
|
||||
} else {
|
||||
if (last > current_n) {
|
||||
maxLen = max(maxLen, length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue