C Language Experience-----An array of elements in the order of operations, find, insert, and delete
to a rookie like me once.
Material Source: HTTP://BLOG.SINA.COM.CN/U/497DC9A1010004T6
////////////////////////////////////////////////////////////
Sequence of arrays (descending sort) module//////
///////////////////////////////////////////////////////////
/*
#include <stdio.h>
#define N 100
Main () {
int a[n],i,j,t;
int k;
printf ("Please enter array size:");
scanf ("%d", &k);
for (i=0;i<k;i++) {
printf (Enter the value of the a[%d] element: ", i);
scanf ("%d", &a);}
for (i=0;i<k;i++) {
for (j=0;j<=k-i-1;j++) {
if (A[j]<a[j+1]) {
T=A[J];
A[J]=A[J+1];
a[j+1]=t;}
}
}
printf (the order of descending sort is:/n);
for (i=0;i<k;i++) {printf ("%d", a);}
}*/
/////////////////////////////////////////////////////
Array element Lookup Module///////////////////
/////////////////////////////////////////////////////
Must consider the question: duplicate element!
/* #include <stdio.h>
Main () {
int I,j, k;
int A[50];
int search;
printf ("Please enter array length:");
scanf ("%d", &k);
for (i=0;i<k;i++) {
printf ("Please enter a[%d] Value:", i);
scanf ("%d", &a);}
printf ("Please enter the number you want to find:");
scanf ("%d", &search);
for (i=0;i<k;i++) {
if (search==a) {break;}
}
for (i=0;i<k;i++) {//Find a duplicate number of cases!
if (search==a)
if (i<k)
printf ("You are looking for the number in%d bits/n", i+1);
Else
printf ("Sorry, there is no number you are looking for.") ");
}
}*/
/////////////////////////////////////////////////////////////////////
The insertion module for the element. //////////////////////////////////
////////////////////////////////////////////////////////////////////
You must consider the problem: after inserting the sort
/* #include <stdio.h>
#define N 100
Main () {
int a[n],i,j,l,t;
int k;
int in;
printf ("Please enter array size:");
scanf ("%d", &k);
for (i=0;i<k;i++) {
printf (Enter the value of the a[%d] element: ", i);
scanf ("%d", &a);}
for (i=0;i<k;i++) {
for (j=0;j<=k-i-1;j++) {
if (A[j]<a[j+1]) {
T=A[J];
A[J]=A[J+1];
a[j+1]=t;}
}
}
printf (the order of descending sort is:/n);
for (i=0;i<k;i++) {printf ("%d", a[i]);
printf ("Please enter the element to insert");
scanf ("%d", &in);
for (i=0;i<k;i++)
{
if (in>a) break;
for (l=k;l>i;l--)//loop to I to stop the search, find the location, then insert, then move the elements back
{A[L]=A[L-1];}
a=in;//inserts elements in the correct position
printf ("/n inserted array elements are:%d/n", in);
printf ("Reorder the element order is:");
for (i=0;i<k+1;i++)
{
printf ("%d", a);
}
printf ("n");
}*/
////////////////////////////////////////////////////////
Element Deletion module///////////////////////////
////////////////////////////////////////////////////////
You must consider the problem: delete the same element
/* #include <stdio.h>
#define N 100
Main () {
int a[n],i,j,t;
int m=0;
int k;
int d;//The element to be deleted.
Char c;//accept user input characters!
printf ("Please enter array size:");
scanf ("%d", &k);
for (i=0;i<k;i++) {
printf (Enter the value of the a[%d] element: ", i);
scanf ("%d", &a);}
for (i=0;i<k;i++) {
for (j=0;j<=k-i-1;j++) {
if (A[j]<a[j+1]) {
T=A[J];
A[J]=A[J+1];
a[j+1]=t;}
}
}
printf (the order of descending sort is:/n);
for (i=0;i<k;i++) {printf ("%d", a);}
printf ("Please enter the element to be deleted:");
scanf ("%d", &d);
m=0;
for (i=0;i<k;i++)
{
if (d==a) {
for (j=i;j<k;j++) a[j]=a[j+1];
M=m+1;
-I.;
}
}
printf (The Reorder Order is:/n);
for (i=0;i<k-m;i++)
printf ("%d", a);
}
*/