#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
float shi;
float xu;
struct Node *next;
}Node,*Linklist;
void insert(Linklist L,float a,float b){
Linklist p,q;
p=L;
while(p->next)
p=p->next;
q=(Linklist)malloc(sizeof(Node));
q->shi=a;
q->xu=b;
q->next=NULL;
p->next=q;
p=q;
}
void search(Linklist L,int count){
Linklist p;
p=L;
while(count){
p=p->next;
count--;
}
printf("%f+%fi\n",p->shi,p->xu);
}
void plus(Linklist L,int count,int countt){
Linklist p,q;
p=L;
q=L;
while(count){
p=p->next;
count--;
}
while(countt){
q=q->next;
countt--;
}
printf("%f+%fi\n",p->shi+q->shi,p->xu+q->xu);
}
void jian(Linklist L,int count,int countt){
Linklist p,q;
p=L;
q=L;
while(count){
p=p->next;
count--;
}
while(countt){
q=q->next;
countt--;
}
printf("%f+%fi\n",p->shi-q->shi,p->xu-q->xu);
}
void ji(Linklist L,int count,int countt){
Linklist p,q;
p=L;
q=L;
while(count){
p=p->next;
count--;
}
while(countt){
q=q->next;
countt--;
}
printf("%f+%fi\n",p->shi*q->shi-p->xu*q->xu,p->* Q- Xu> Shi + Q-> p-Xu *> Shi);
}
void searchshi(Linklist L,int count){
Linklist p;
p=L;
while(count){
p=p->next;
count--;
}
printf("实部是%f\n",p->shi);
}
void searchxu(Linklist L,int count){
Linklist p;
p=L;
while(count){
p=p->next;
count--;
}
printf("虚部是%f\n",p->xu);
}
void main () {
the printf ( "Experimental data structure, a plurality of \ n-");
the printf ( "Operation and numbered as follows:. \ n1 input real and imaginary parts generates a plurality of \ n2 plurality view entered \ n-.") ;
the printf ( "two complex summation. 3 \ n-.");
the printf (. ". 4 differencing two complex \ n-");
the printf ( "plural two quadrature. 5 \ n-.");
. the printf ( "separated. 6 the real part \ n-");
the printf (" separating the imaginary part. 7 \ n-. ");
the printf (" 0 exit \ n-");.
Linklist L;
L = (Linklist) the malloc (the sizeof (the Node));
L- > Next = NULL;
int I, J;
int COUNT = 0, countt = 0, Choice = 0;
the while (. 1) {
the printf ( "enter operation number \ n-");
Scanf ( "% D", & Choice);
IF (! (Choice))
BREAK;
Switch (Choice) {
Case. 1: {
the printf ( "input respectively the real part and the imaginary part \ n-");
Scanf ( "%d",&i);
scanf("%d",&j);
insert(L,i,j);
BREAK;
}
Case 2: {
the printf ( "Enter the view of several complex \ n-");
Scanf ( "% D", & COUNT);
Search (L, COUNT);
BREAK;
}
Case. 3: {
the printf ( "respectively input summing two complex number, after the first small large \ n-");
Scanf ("% D ", & COUNT);
Scanf ("% D ", & countt);
PLUS (L, COUNT, countt);
BREAK;
}
Case . 4: {
the printf ( "are input differencing two complex number \ n-");
Scanf ( "% D", & COUNT);
Scanf ( "% D", & countt);
Jian (L, COUNT, countt);
BREAK;
}
Case. 5: {
the printf ( "enter Quadrature respectively two complex number \ n-");
Scanf ( "% D", & COUNT);
scanf("%d",&countt);
ji(L,count,countt);
break;
}
Case. 6: {
the printf ( "Enter number to see which of the real part \ n-");
Scanf ( "% D", & COUNT);
searchshi (L, COUNT);
BREAK;
}
. 7 Case: {
the printf ( "Enter to see which imaginary number portion \ n-");
Scanf ( "% D", & COUNT);
searchxu (L, COUNT);
BREAK;
}
}
}
}