Помогите пожалуйста, для зачета сделал программу, но она работает не так, как хотелось бы, подскажите ошибочку пожалуйста...
Само задание:
[Ссылки могут видеть только зарегистрированные пользователи. ]
Моё решение:
main.c
Код:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int tab(float , float , float , float(*) (float));
float Rainmeter(float );
int main (int argc, char *argv[]){
float a,b,h;
printf("Vvedite otrezok ot a do b i shagom h\n");
scanf("%f %f %f",&a,&b,&h);
printf("%f %f %f\n",a,b,h);
if (tab(a,b,h,Rainmeter)==0 ){printf("Programma zavershilas uspeshno");}
return 0;
}
lab.c
Код:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int tab(float a, float b, float h, float(*f) (float)){
float x;
FILE *fout;
if ((fout=fopen("Data.dat","w"))==NULL){
printf ("\n Ne mogu otkrit %s\n","Data.dat");
return 1;
}
for (x=a; x<=b; x=x+h){
printf ("%f %f \n",x,(*f)(x));
fprintf(fout,"%f %f \n",x,(*f)(x));
}
return 0;
}
# This is an Makefile example.
# make is useful utilite to easyly build executable file(s)
# from source files. If you have file named Makefile in
# current directory you can just type 'make' to create
# final executable files using libraries and so on.
# You can type something similar to 'make clean' to do cleaning
# your directory from old files or other things.
# Please, use 'man make' to get more information.
# First, we define some macros (it may be omitted)
# for example, the source files of our project
# SRC = myfunc.c
# the object files
# OBJ = myfunc.o
LIB = libMy.a
LIBSRC = lab.c my2.c
LIBOBJ = lab.o my2.o
# MYLIB = libMy.a
# the files what we are going to archive
#ARCHIVE = $(SRC) Makefile
# the file where we want store the archive.
#ARCH_FILE = labs
# This is strangle way to get short library name from long one.
#LIBNAME = `expr $(LIB) : '...\(.*\)..'`
# $1 2>$x.err
# -o $x $x.o -lsimul -L/home/zhur/SIMULATE/FORT>>$x.err
FFLAGS = -Wall -c
# Next, we define the targets and their dependences.
# To get a correct target we need the up-to-day dependencies.
# The make utilite automaticaly cheks it and remades only
# files that were be changed after last building the target.
# The first target will be made in you typed 'make'.
# In this example the next line may be omitted or
# additional dependences may be set, for example
# all: lab1 lab2 ...
all:
gcc $(FFLAGS) $(LIBSRC)
ar vr libMy.a $(LIBOBJ)
# Other targets will be made (or remade) only if we specify
# the target name in command line or if target depends on
# other targets which should be remade.
# After this line you can put shell commands.
# NOTE: <TAB> must be put before command (not SPACES).
#nmslib: $(LIB)
# gfortran $(FFLAGS) $(LIBSRC)
# ar vr libNMS.a $(LIBOBJ)
# The 'lab1' target needs up-to-date library 'libmy.a' (see macros
# definitions at the top of the file). The 'libmy.a' target
# needs up-to-date objects files. Note that 'make' utilite knows
# how to make library from object file (it even uses different commands
# 'a' or 'r' depend on existion object file in library) and
# object file from FORTRAN file. We remove object files
# after putting in library to free disk space.
$(LIB): $(LIB)($(LIBOBJ))
rm -f $?
clean:
rm -f *.o lib*.a
# 'make tgz' used to make archive file. This file will be packed
# to reduce disk space usage. You must have path '/usr/local/bin'
# in your PATH environment variable (see your $HOME/.profile).
#tgz:
# tar cvf $(ARCH_FILE).tar $(ARCHIVE)
# gzip $(ARCH_FILE).tar
# mv -f $(ARCH_FILE).tar.gz $(ARCH_FILE).tgz
После чего ввожу значение a,b и шаг h, но почему-то он просит ввести 4-ое значение.И далее мне выдает примерно такое:
Хотя во втором столбце должно быть не это(не знаю что должно быть, но точно не это).
Помогите пожалуйста решить.
Добавлено через 2 минуты
Кстати в какой программе можно программы на Си писать на виндовсе? А то в универе Geany стоит, но качаю я какую-то левую . Да и система там другая
Последний раз редактировалось KrucK; 26.06.2012 в 17:30.
Причина: Добавлено сообщение