📄 printlist.c
字号:
#include "myfun.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
/*函数功能:显示名单
函数参数:struct equipage型指针变量p,表示结构体数组地址
整型变量n,表示选手人数
函数返回值:无
*/
void PrintList(struct equipage *p,int n)
{
char t = '\0';
int m;
struct equipage *q = NULL , *p1 = NULL;
p1 = p;
m = n;
do
{
int i = 1;
system("cls");
printf("\n");
printf("\t\t\t|-----------------------------------|\n");
printf("\t\t\t| Please enter a number (1--3): |\n");
printf("\t\t\t| |\n");
printf("\t\t\t| 1--Print in order |\n");
printf("\t\t\t| 2--Print in reverse order |\n");
printf("\t\t\t| 3--Return to Main Menu |\n");
printf("\t\t\t| |\n");
printf("\t\t\t|-----------------------------------|\n");
printf("\nyour choice is : ");
t = getche();
while (t < '1' || t > '3') { Alarm(); t = getche(); }
if(t == '1') /*正序显示*/
{
system("cls");
printf("No. Rider IDnum Rider Name Nation/Club Horse IDnum Horse Name H_age\n");
while(n > 0)
{
printf("%-3d %-11s %-15s%-11s %-11s %-15s%-2d\n",i,p->license,p->name_r,p->nation,p->ident,p->name_h,p->age);
p++;
n--;
i++;
}
p = p1; /*还原p与m的原有指向*/
n = m;
printf("\n\nPress any key to return ....");
getch();
}
if(t == '2') /*倒序显示*/
{
system("cls");
q = p + n - 1;
printf("No. Rider IDnum Rider Name Nation/Club Horse IDnum Horse Name H_age\n");
while(n > 0)
{
printf("%-3d %-11s %-15s%-11s %-11s %-15s%-2d\n",n,q->license,q->name_r,q->nation,q->ident,q->name_h,q->age);
q--;
n--;
}
p = p1;
n = m;
printf("\n\nPress any key to return ....");
getch();
}
} while (t != '3');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -