1. Write the function to determine whether the character entered by the user is a symmetric string (that is, a string that is the same as the Read and rewind). For example, "Xyzyx" and "Xyzzyx" are symmetrical.
#include <stdio.h>intMain () {Charstr[ -]; intI=0, A,b,j,k; Gets (str); while(str[i]!=' /') I++; if(i%2==0) {a=i/2-1; b=i/2; } Else{a=i/2-1; b=i/2+1; } for(j=a,k=b;j>=0, K<=i;j--, k++) { if(str[j]!=Str[k]) Break; } if(k==i+1) printf ("yes\n"); Elseprintf ("no.\n");}
2. The write function uses the bubbling sort method to sort the number of entries (or student names) entered by the user in ascending order.
#include <stdio.h>#include<string.h>voidF1 () {Chara[ -]; intlength,j,i,temp; printf ("Please enter:"); scanf ("%s", a); Length=strlen (a); for(j=0; j<length;j++) { for(i=length-1;i>0; i--) { if(a[i]<a[i-1]) {temp=A[i]; A[i]=a[i-1]; A[i-1]=temp; }}} printf ("sort it in ascending order:"); for(i=0; i<length;i++) printf ("%c", A[i]); }intMain () {F1 (); return 0;}
3. Write the function use the Select Sort method to sort the number of entries (or student names) entered by the user in ascending order.
#include <stdio.h>intMaxinta[]) { inti,j,t; for(i=0;i<Ten; i++) for(j=i+1;j<Ten; j + +) if(a[i]>A[j]) {T=A[i]; A[i]=A[j]; A[J]=T; }}intMain () {inta[Ten],i; printf ("Enter a 10 number:"); for(i=0;i<Ten; i++) scanf ("%d",&A[i]); Max (a); for(i=0;i<Ten; i++) printf ("%d", A[i]); return 0; }
4. Write the function to sort the number of entries (or student names) entered by the user in ascending order using the insertion sort method.
#include <stdio.h>intMain () {inta[ -]; inti,temp,j; printf ("Please enter:"); scanf ("%d", a); for(i=1;i< -; i++) {Temp=A[i]; J=i-1; while(j>=0&&temp<A[j]) {A[j*1]=A[j]; J--; } a[j*1]=temp} printf ("Sort Ascending to:")}
I did my best, really.
C Language 9th time assignment