General:
# include & ltstdio.h & gt?
# include & ltgraphics.h & gt?
# include & ltconio.h & gt?
Invalid? main()?
{?
Charles? str?
int? I,k,choice = 1; ?
int? gd=DETECT,GM; ?
init graph(& amp; Gd,&, "?" ); ?
setbkcolor(2); ?
settextstyle(3,0,3); ?
outtextxy( 140, 120," a? That? Mock? Clock. ”); ?
outtextxy( 140, 150," b? That? Numbers? Clock. ”); ?
outtextxy( 140, 180," c? Quit ”); ?
setlinestyle(0,0,3); ?
Rectangular (170,115,370,145); ?
/* Press the up and down keys to select the desired option */?
for(I = 1; I<= 100; i++)?
{?
str = getch(); ?
if(str==72)?
{?
-choice; ?
if(choice = = 0)choice = 3; ?
}?
if(str==80)?
{?
++selection; ?
if(choice = = 4)choice = 1; ?
}?
if(str = = 13)break; ? /* Press Enter to confirm */?
/* Draw a picture and make a menu */?
clear device(); ?
Switch (select)?
{? Case? 1:? setlinestyle(0,0,3); ?
Rectangular (170,115,400,145); ?
settextstyle(3,0,3); ?
outtextxy( 140, 120," a? That? Mock? Clock. ”); ?
settextstyle(3,0,3); ?
outtextxy( 140, 150," b? That? Numbers? Clock. ”); ?
outtextxy( 140, 180," c? Quit ”); ?
Break; ?
Case? 2:? setlinestyle(0,0,3); ?
Rectangular (170,145,400,175); ?
settextstyle(3,0,3); ?
outtextxy( 140, 120," a? That? Mock? Clock. ”); ?
settextstyle(3,0,3); ?
outtextxy( 140, 150," b? That? Numbers? Clock. ”); ?
settextstyle(3,0,3); ?
outtextxy( 140, 180," c? Quit ”); ?
Break; ?
Case? 3:? settextstyle(3,0,3); ?
outtextxy( 140, 120," a? That? Mock? Clock. ”); ?
outtextxy( 140, 150," b? That? Numbers? Clock. ”); ?
settextstyle(3,0,3); ?
outtextxy( 140, 180," c? Quit ”); ?
setlinestyle(0,0,3); ?
Rectangular (170,175,400,205); ?
Break; ?
}?
}?
If (i>= 100) exits (0); /* If the number of keystrokes exceeds 100, exit */?
Switch(choice)/* Here is the reference function */?
{?
Case? 1:? clear device(); ?
setbkcolor(4); ?
settextstyle(3,0,4); ?
Outtextxy( 160, 120, "No.65438 +0? Really? Isn't it? Built. " ); ? Break; ?
Case? 2:? clear device(); ?
setbkcolor(4); ?
settextstyle(3,0,4); ?
Outtextxy( 160, 150, "No.2? Really? Isn't it? Built. " ); ?
Break; ?
Case? 3:? Exit (0); ?
}?
getch(); ?
closegraph(); ?
} For the command line menu, directly simulate the menu behavior by constantly refreshing the output.
General:
# Contains? & ltstdio.h & gt
# Contains? & ltstdlib.h & gt?
# Contains? & ltstring.h & gt
int? n,t,k;
int? m;
Charles? s 1[20],s2[20],c;
Charles? * * l;
Charles? *num[]={ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" and "ten"};
Invalid? Menu ()
{
printf(" \ n \ n \ t \ t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf("\t\t** 1。 Find the number of occurrences of S2 in the string S 1 **\n ");
Printf("\t\t**2。 Calculate the uppercase and lowercase letters in the string and the number of times the number appears * * \ n ");
Printf("\t\t**3。 Translate the numbers into English? * * \ n ");
Printf("\t\t**4。 End? * * \ n ");
printf(" \ t \ t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
printf("\t\t? Your input: ");
fflush(stdin);
scanf("%d ",& ampn);
}
Invalid? Check ()
{
Charles? a[20],b[20];
int? j=0,k,m,l = 0;
int? t=0,n = 0;
Printf ("Please enter main string: \ n");
scanf("%s ",a);
k = strlen(a);
Printf ("Please enter substring: \ n");
scanf("%s ",b);
m = strlen(b);
for(n = 0; n & ltk; n++)
if(a[n]==b[0])
{
j++; ? /* Record the same number of characters */
do
{
if(a[++n]==b[++t])
{?
j++;
if(j==m)?
{
l++; /* Same number of substrings */
j = 0; /* After judgment, the same number of characters will return to zero */
t =- 1; /* If judging++t; T will return to zero */
}
}
other
{
j = 0;
t = 0;
Break; /* If not, jump out of the while loop and let for make n+ 1 continue to judge */
}
}while(a[n]! ='\0'); /* Search the end of character array A */
}
Printf ("substring occurrences: \n%d\n", l);
}?
Invalid? cout()
{
int? n=0,t=0,k = 0;
Printf ("Please enter a string: \ n");
fflush(stdin); /* Clear the buffer */
while((c=getchar())! ='\n ')
{
if(c & gt; = ' a ' & amp& ampc & lt='z ')
n++;
if(c & gt; = ' A ' & amp& ampc & lt='Z ')
t++;
if(c & gt; = ' 0 ' & amp& ampc & lt='9')
k++;
}
Printf ("with capital letters: \n%d\n", t);
Printf ("with lowercase letters: \n%d\n", n);
Printf ("with number: \n%d\n", k);
}
Invalid? Number ()
{
l = num
Printf ("Please enter a number: (0-10) \ n");
fflush(stdin);
scanf("%d ",& ampm);
Printf (English for "d" is: \n%s\n ",m, * (l+m-1));
}
Invalid? Master ()
{
while( 1)
{
System ("CLS");
menu();
Switch (n)
{
Case? 1:system(" cls "); check(); System ("suspended"); Break;
Case? 2: System ("CLS"); cout(); System ("suspended"); Break;
Case? 3: System ("CLS"); number(); System ("suspended"); Break;
Case? 4: System ("CLS"); Break;
Default value: system ("CLS"); Break; ?
}
What if (n==4)? Break;
}
Printf ("Thanks for using \ n");
}