Rewrite requirement 1: Implemented with single-linked list
#include <cstdlib>#include<iostream>using namespacestd;structlinknode{intdata; Linknode*next;};classpalindrome{intLow,up; inta[ -]; intcount; Public: Palindrome (intT1,intT2); intIspalin (intx); Linknode*Ispalinandstore (); voidOutputresults (linknode*Head);}; Palindrome::P alindrome (intT1,intT2) {Count=0; Low=T1; up=T2;} Linknode*Palindrome::ispalinandstore () {Linknode* head=NewLinknode; Head->next=NULL; Linknode* p=Head; for(inti=low;i<=up;i++) { intx=i*i; if(Ispalin (x)) {Linknode* newlinknode=NewLinknode; Newlinknode->next=NULL; Newlinknode->data=i; P->next=Newlinknode; P=Newlinknode; } } returnHead;}voidPalindrome::outputresults (linknode*Head) {Linknode* p=head->Next; cout<<"count="<<count<<Endl; cout<<"x"<<'\ t'<<"x*x"<<Endl; while(p) {cout<<p->data<<'\ t'<<p->data*p->data<<Endl; P=p->Next; }}intPalindrome::ispalin (intx) { intI=0, J,n; inta[ -]; while(x) {A[i]=x%Ten; X=x/Ten; I++; } N=i; for(i=0, j=n-1; i<=j;i++,j--) if(a[i]!=A[j])return 0; return 1;}intMainintargcChar*argv[]) {Linknode* head=NewLinknode; Palindrome P ( -, +); Head=P.ispalinandstore (); P.outputresults (Head); System ("PAUSE"); returnexit_success;}
C + + Programming practice Guidance 1.15 Find the palindrome number rewrite requirements to achieve