程序题哪儿位大哥来帮帮忙!谢谢了.急用版主帮看看
以下就是提谢谢大家帮忙了!!!!请解答一下!!
<<<要求通过变量的改变使用link-list 在坐标轴上实现增加一条正旋曲线,减少一条曲线,以及编辑一条曲线。
公式y = amplitude* sin e (2π* time* frequency + phase)
t 时间为变量, amplitude 振幅,frequency 频率, phase 角度 为程序设计者自设参数变量, 需要自己设定取值范围。
通过输入不同的振幅,频率,以及角度在坐标轴上画不同曲线,在删除,编辑曲线的时候可以是坐标轴上任意一条曲线,也可以指定一条曲线删除或是编辑。
最后,画一条正旋曲线,实现坐标轴上所保留的所有曲线,波峰波峰叠加,波谷波谷叠加。
程序的所有设计都要自己完成,比如如果画坐标轴,坐标轴上刻度的选择,总之就是从开始到最后都要自己设计。
link-list
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
typedef struct opamp_type /*declare strecture for*/
{ /*Op-Amp database*/
char type[20]; /*type*/
char make[20]; /*manufactrer*/
int powerdis; /*power dissipation*/
double slew; /*slew rate*/
double supcurrent; /*supply current*/
double price; /*retail price*/
struct opam_type*next; /*link to next item in list*/
struct opam_type /*link to former item in*/
*former; /*list*/
} OPAMP;
void print_form(void) /*display labels for*/
{ /*items on screen*/
gotoxy(25,10);printf("Tyoe: ");
gotoxy(25,11);printf("Make: ");
gotoxy(25,12);printf("Power dissipation: ");
gotoxy(25,13);printf("Slew: ");
gotoxy(25,14);printf("Supply current: ");
gotoxy(25,15);printf("Price: ");
}
void print_opam (OPAM /*function to print*/
*ITEM) /*current 0p-Amp details*/
{ /*to screen*/
clrscr ();
if (item==NULL /*items on screen*/
{
gotoxy(20,5);
printf(" ");
gotoxy(2o,5);
printf(" Empty list ");
}
else /*otherwise display Op-Amp parameters*/
{
gotoxy(20,5);
printf(" ");
gotoxy(2o,5);
printf(" Op-Amps-bi-polar type ");
print_form();
gotoxy(40,10);printfy("%s",item->tpye);
gotoxy(40,11);printfy("%s",item->make);
gotoxy(40,12);printfy("%s",item->powerdis);
gotoxy(40,13);printfy("%s",item->slew);
gotoxy(40,14);printfy("%s",item->supcurrent);
gotoxy(40,15);printfy("%s",item->price);
}
}
OPAM*new_opam(OPAMP /*add Op-Amp parameters to*/
*item) /*the end of the linked*/
/*list*/
{
OPAMP*new_opamp;
gotoxy(20,5)
printf(" Add an Op-Amp to the end of the list ");
print_form();
new_opamp=(OPAM*) /*reserve memory*/
malloc(sizeof(OPAM)); /*point to NULL*/
new_opam->next=NULL;
gotoxy(44,10); /*read in values for*/
scanf("%s",item->tpye); /*parameters and*/
gotoxy(44,11); /*assign to*/
scanf("%s",item->tpye); /*structure*/
gotoxy(40,12);printfy("%s",item->powerdis);
gotoxy(40,13);printfy("%s",item->slew);
gotoxy(40,14);printfy("%s",item->supcurrent);
gotoxy(40,15);printfy("%s",item->price);
if (item!=NULL) /*if this is not the first item*/
{
item->next=new_opap /*make links to the*/
new_opap->former=item; /*previous item in the*/
} /*list*/
else new opam->former=NULL; /*otherwise NULL*/
/*former pointer*/
return(new_opam);
}
OPAMP*next_opamp(OPAP*item) /*move to next Op-Amp*/
{ /*in list*/
if (item!=NULL) /*make sure we have the link*/
{
if (item=item->next!=NULL;) /*make sure the link*/
{ /*is not NULL*/
item=item->next /*if OK-move to next*/
}
else /*otherwise inform the user that the*/
{ /*end of the list has been reached*/
gotoxy(20,5)
printf(" ");
gotoxy(20,5)
printf(" End of list ");
}
}
return (item);
}
OPAMP*former_opamp(OPAMP*item) /*move to the former*/
{ /*Op-Amp in list*/
if (item!=NULL) /*make sure we have a link*/
{
if (item->former!=NULL) /*make sure the link is*/
{ /*not NULL*/
item=item->former; /*if OK-move to former item*/
} /*in the list */
else /*otherwise inform the user that the */
{ /*beginning of the list has been reached*/
gotoxy(20,5)
printf(" ");
gotoxy(20,5)
printf(" Beginning of lsit ");
}
}
return (item);
}
OPamp*delete_opamp(OPAMP*) /*delete item from*/
{ /*list*/
OPAMP*previous,*following;
if (items!=NULL) /*ensure item exissts to delete!*/
{
previouse=item->former; /*assign former and next*/
following=item->next; /*links to pointers*/
/*accordingly*/
if (previouse!=NULL) /*reoute around*/
previouse->next=following; /*item*/
if (following!=NULL) following->former=previous;
free(item); /*release the item's memory*/
if (previouse!=NULL) /*reassign the pointer item*/
item=previous; /*the current item*/
else item=following;
}
return(item);
}
OPAMP*find_opamp(opamp*item) /*locate a particular*/
{ /*item in the list*/
char optype[20];
int opamp_found=0;
if (intm!=NULL) /*make sure we have a list to search*/
{
clrscr(); /*ask user for details of tpye of*/
gotoxy(20,5); /*Op-Amp to be loacted*/
printf(" Locate an OPAMP type in the list"/
gotoxy(20,10);printf("Type: ");
gotoxy(44,10);scanf("%s",optype ");
}
while ((item->next!=NU;;)&& /*search list*/
(!opamp_found))
{
if (!stramp(optype,item->tpye))/*test each*/
opamp_found=1; /*item held*/
else item=item->next;
}
return(item); /*return pointer to loacted item or*/
} /*the end of the list*/
int main(void) /*main function*/
{
OPAMP*first=NULL,*current=NULL,/*pointers used*/
*last=NULL /*for list*/
char response;
do /*repeat until'q'hit*/
{
print_opamp(current); /*print current item in list*/
/*to screen display commandt*/
/*options*/
gotoxy(25,18); printf9"'d':delete the current opam entry");
gotoxy(25,19); printf9"'a':add an opamp entry");
gotoxy(25,20); printf9"'f':find an opamp in the list");
gotoxy(25,21); printf9"'n':show the previous entry");
gotoxy(25,22); printf9"'p':show the next entry");
gotoxy(25,23); printf9"'r':return to start of list");
gotoxy(25,34); printf9"'q':quit the database");
gotoxy(40,26); putch(''); /*overwrite old command*/
gotoxy(25,46);
printf("Enter command:") /*get new command*/
response=getch();
gotoxy(40,26) /*print new command*/
putch(response); /*to screen*/
switch(response) /*call relevant function*/
{
case'd':current=delete_opamp(current); break;
case'a':current=last=add_opamp(last); break;
case'f':current=find_opamp(first); break;
case'p':current=former_opamp(current); break;
case'n':current=next_opamp(current); break;
case'r':current=first; break;
}
if (first==NULL) first=last; /*assign pointers to*/
/*first item*/
/*provided in list*/
if (current==NULL) first=last=NULL;
} while (resonse!='q'); /*repeat untial a 'q' is hit*/
return (0)
}
请勿随意丢弃废旧电池,一个5号电池可将5平方米土地重金属污染达50年!!
>>>