main.c文件
#include <stdio.h>
int main()
{
#include "p.txt"
}
p.txt
printf("锄禾日当午,学C真他妈哭1");
菜单技术
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
char get_choice(void );
char get_first(void);
void count(void);
int get_int(void );
void count(void)
{
int n ,i ;
printf(" count how far \n");
n = get_int();
for (int i = 1; i <= n ; i++)
{
printf("%d \n ",i);
}
while (getchar()!= '\n')
{
continue;
}
}
char get_first(void)
{
int ch ;
ch = getchar() ;
while (getchar() != '\n') {
continue;
}
return ch;
}
char get_choice(void )
{
int ch;
printf(" enter the letter of your choice \n");
printf("a.advice b.bell \n");
printf("c.count q.quit \n");
ch = get_first();
while ((ch < 'a' || ch > 'c' ) && ch != 'q' ) {
printf(" plese respond with a, b, c, or q .\n");
ch = get_first();
}
return ch ;
}
int get_int(void )
{
int input ;
char ch ;
while (scanf(" %d" , &input) != 1 ) {
while ((ch = getchar()) != '\n') {
putchar(ch);
}
printf("is not an integer ");
}
return input;
}
void main()
{
int choice;
void count (void);
while ((choice = get_choice()) != 'q') {
switch (choice) {
case 'a':
printf(" buy low , sell high \n");
break;
case 'b':
putchar('\a');
break;
case 'c':
count();
break;
case 'd':
printf(" buy low , sell high \n");
break;
default:
break;
}
}
}
网友评论