problem mit nem programm zum plotten der sin/cos funktion
-
hi hab hier mal ein prob!
ich weiß einfach nit wie ich anfangen soll mit dem prog.wie kann ich ein koordinatenkreuz erstellen mit ner doppelten char funktion was die maßen 80*25 hat und wie beschrifte ich das dingen????
wäre nett wenn mir jemand helfen könnte denn den rest den hab ich wohl mir fehlt nur dsa koordinatenkreuz!!!
diese beiden datein habe ich schon aber ich weiß nicht da fehtl noch was und ich bekommen es nicht hin:
#ifndef TEXTPLOTT_H_
#define TEXTPLOTT_H_#define ROWS 25
#define COLS 80
#include <stdio.h>char feld[ROWS][COLS];
int xintervall;
int yintervall;
int xachse;/** initialize the plotter */
void clearPlotter(){
int r=0,c=0;
for(r=0; r<=ROWS; r++){
for(c=0; c<=COLS; c++){
feld [r][c] ='.';
}
}
}/** print plotter array to stdout */
void showPlotter(){
int r,c;
for (r=0; r<ROWS; r++){
for(c=0; c<COLS+1; c++){
if(c<COLS){
putchar(feld[r][c]);
}
else printf("\n");
}
}
}/** set the plott area coordinates */
void setPlottArea(float x0, float y0, float x1, float y1){
int c,r;
c = x1-x0;
r = y1-y0;
xintervall = COLS/c;
yintervall = ROWS/r;
xachse = x0;
printf("xintervall=%d, yintervall=%d\n", xintervall,yintervall);
}/** plott char at coordinate (y,x) */
void plott(float x, float y, char ch);/** utility method to draw x,y axes */
void plott_Axes(){
int c,r,ra;
for (c=0;c<COLS;c++){
if(c-xachse==2){
for (ra=0;ra<ROWS;ra++){
feld[r][ra]='|';
}
}
}
for (c=0;c<COLS;c++){
if (c%xintervall){
feld[r][c]='-';
}
else
feld[r][c]='+';
}
}#endif /*TEXTPLOTT_H_*/
und die:
#include <math.h>
#include "textplott.h"int main(int argc, char argv[]){
/*float x,y;*/
clearPlotter();
setPlottArea(-5,-1.2,6.3,1.2);
/for(x=0; x < 6; x+=0.01){
y = sin(x);
plott(x,y,'');
y = cos(x);
plott(x,y,'+');
}/
plott_Axes();showPlotter();
return 1;
}wäre cool wenn mir jemand helfen könnte!
