Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 26.06.2012, 18:20   #1
Alexey22rus
Новичок
Джуниор
 
Регистрация: 26.06.2012
Сообщений: 1
По умолчанию Табулирование функций (Си)(Geany желательно)

Помогите пожалуйста, для зачета сделал программу, но она работает не так, как хотелось бы, подскажите ошибочку пожалуйста...
Само задание:


Моё решение:
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;
}
my2.c
Код:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define V 1
#define V0 2
#define a 3

float Rainmeter(float t){
	float S;
	S=((V*V)-(V0*V0))/(2*a);
//	printf ("Respons %f\n",F);
	return S;
}
Библиотека:
Makefile
Код:
# 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-ое значение.И далее мне выдает примерно такое:
Код:
1.0000000 0.0000000
2.0000000 0.0000000
3.0000000 0.0000000
4.0000000 0.0000000
5.0000000 0.0000000
Хотя во втором столбце должно быть не это(не знаю что должно быть, но точно не это).
Помогите пожалуйста решить.

Добавлено через 2 минуты
Кстати в какой программе можно программы на Си писать на виндовсе? А то в универе Geany стоит, но качаю я какую-то левую /problem. Да и система там другая

Последний раз редактировалось Alexey22rus; 26.06.2012 в 18:26.
Alexey22rus вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Табулирование функций rustik24 Паскаль, Turbo Pascal, PascalABC.NET 7 09.02.2012 16:01
Табулирование функций serega2363 Паскаль, Turbo Pascal, PascalABC.NET 0 09.11.2011 20:04
Табулирование функций Sergey_Zelenev C# (си шарп) 4 29.03.2011 20:55
Табулирование функций. Mambakremen Помощь студентам 5 08.11.2010 00:24
Табулирование функций. Dog Помощь студентам 1 27.09.2009 21:25