/***************main.c************************************************************************/
#include #include #include "list.h" int IsEven ( int n ) ; List PowPolynomial ( List L, int n ) ;//??????L??n???? List PolyMultiply ( List L1, List L2 ) ;//??????L1??L2???? int main ( void ) { List L ; int n ; ElementDouble d ; ElementInt index ; L = CreatList () ; printf ( "Please input a polynomial:\n" ) ; scanf ( "%lf%d", &d, &index ) http://michaelkorsoutletonlinefor.webs.com - michael kors factory outlet ; while ( d != 0 ) { Insert ( d, index, L ) ; scanf ( "%lf%d", &d, &index ) ; } Print ( L ) ;
printf ( "Please input polynomial index:" ) ; scanf ( "%d", &n ) ; if ( 0 == n ) { printf ( "Polynomial : 1\n" ) ; return 0 ; } else if ( 1 == n ) Print ( L ) ; else { L = PowPolynomial ( L, n ) ; Print ( L ) ; } DisposeList ( L ) http://michaelkorsoutletonlinefor.webs.com - michael kors outlet online ; return 0 ; } List PowPolynomial ( List L, int n ) { if ( 1 == n ) return L ; else { if ( IsEven ( n ) ) return PowPolynomial ( PolyMultiply ( L, L ), n / 2 ) ; else return PolyMultiply ( PowPolynomial ( PolyMultiply ( L, L ), n / 2 ), L ) ; }
} List PolyMultiply ( List L1, List L2 ) { List L ; Position p1, p2 ; p1 = L1 -> Next ; p2 = L2 -> Next ; if ( NULL == p1 NULL == p2 ) return NULL == p1 ? L2 : L1 ; L = CreatList () ; while ( p1 != NULL ) { p2 = L2 -> Next ; while ( p2 != NULL ) { Insert ( p1 -> D * p2 -> D, p1 -> Index + p2 -> Index, L ) ; p2 = p2 -> Next ; } p1 = p1 -> Next http://michaelkorsoutletonlinehu.webs.com - michael kors outlet online ; } return L ; } int IsEven ( int n ) { return 0 == n % 2 ; }This procedure is what I write.But insert inaccuracy.After inserting, the total amount of chemical elements on the contrary reduced #include #include
typedef int DataType ; typedef struct Node { DataType data; struct Node *next; }LNode, *PNode, *LinkList;
//Build up chain form int InitList(LinkList *h) { *h = (LinkList)malloc(sizeof(LNode));
if (!h) { Printf("the beginning starts to turn chain form wrong\ n"); return 0; } (*h)->next = NULL;
return 1; } //The form is long int ListLength (LinkList h) { int total = 0; PNode p = h->next; while(p) { total++; p = p->next; } return total; } //The judgment gets empty form int ListEmpty(LinkList h) { if (h->next) return 0; else return 1; } //Insert Int ListInsret(LinkList h, int pos, DataType x)//the pos is a plug-in position, x for need a plug-in chemical element { PNode p = h, q http://michaelkorsoutletonlinehu.webs.com - http://michaelkorsoutletonlinehu.webs.com ;
int i = 0; while (p && i < pos -1) //p != NULL { p = p->next; i++; }
if (!p i > pos - 1) //!P:p ==NULL { Printf("the position inserting is illegal"); return 0; }
q = (PNode)malloc(sizeof(LNode)); //Heart crunode if (!q) { Printf("not the ability is born new of node"); return 0; } q ->data = x; q->next = p->next; p->next = q;
return 1; }
//Delete Int ListDelete(LinkList h, int pos, DataType*item)//the pos delete position, item's returning is deleted a chemical element { PNode p = h, q; int i = 0;
while (p->next && i < pos - 1) { p = p->next; i++; }
if (!p->next i > pos - 1) { Printf("the position deleting is illegal"); return 0;
}
q = p->next; p->next = q->next; *item = q->data;
free(q);
return 1; }
//Check to seek
PNode Find(LinkList h, DataType item) { PNode p = h->next; while (p && p->data!=item) p = p->next; return p; }
//Time Li void Traverselist (LinkList h) { PNode p = h->next; while (p) { printf("%d ", p->data); p = p->next; } printf("\n"); }
//Lord function int main(void) { int i, pos, x, pos1, item, qq; int data[10]; LNode *kk; LinkList h = NULL; InitList(&h);
Printf("please input 10 piece values:"); for (i = 0; i < 10; i++) { scanf("%d", &data[i]); }
for (i = 0; i < 7; i++) { if (!ListInsret(h, i+1, data[i])) { Printf("insert an operation mistake!\n"); return 0; }
} Printf("dollar chain form:"); for (i = 0; i < 10; i++) { printf("%d ", data[i]); } printf( "\n"); //Insert
Printf("please input a plug-in position and chemical element:"); scanf("%d%d", &pos, &x);
if (!ListInsret(h, pos, x)) printf("erroe"); Printf("insert the chain form after:"); Traverselist(h);
//Delete Printf("invite the position of inputing the deletion:"); scanf("%d", &pos1);
if (!ListDelete(h, pos1, &item)) printf("erroe"); Printf("delete the chain form after:"); Traverselist(h);
//Check to seek
Printf("please input to check to seek of data:"); scanf("%d", &qq);
kk = Find( h, qq);
Printf("this chain form has the data of importation:%d\n", kk->data);
return 0;
}SFZH=[141027197802163033]
*- Judge ID card length IF LEN(SFZH)!=18 MESSAGEBOX([ID card number length BE]+TRANSFORM(LEN(SFZH))+[]) ENDIF
*- Judge
- http://jd.paolunt.com/forum.php?mod=viewthread&tid=18173 - michael kors outlet gns888
- http://videos.dianna-a.org/members/slidny92 - michael kors outlet online xcn378
|