2024年4月19日发(作者:)

摘自 宋鲁生 程序设计大赛

乘法口诀表

#include

#include

void main(void)

{

int i,j,x,y;

clrscr();

printf("nn * * * 乘法口诀表 * * * nn");

x=9;

y=5;

for(i=1;i<=9;i++)

{

gotoxy(x,y);

printf("%2d ",i);

x+=3;

}

x=7;

y=6;

for(i=1;i<=9;i++)

{

gotoxy(x,y);

printf("%2d ",i);

y++;

}

x=9;

y= 6;

for(i=1;i<=9;i++)

{

for(j=1;j<=9;j++)

{

gotoxy(x,y);

printf("%2d ",i*j);

y++;

}

y-=9;

x+=3;

}

printf("nn");

}

用一维数组统计学生成绩

#include

void main()

{

char SelectKey,CreditMoney,DebitMoney;

while(1)

{

do{

clrscr();

puts("=========================");

puts("| Please select key: |");

puts("| 1. Quary |");

puts("| 2. Credit |");

puts("| 3. Debit |");

puts("| 4. Return |");

puts("=========================");

SelectKey = getch();

}while( SelectKey!='1' && SelectKey!='2' && SelectKey!='3' &&

SelectKey!='4' );

switch(SelectKey)

{

case '1':

clrscr();

puts("================================");

puts("| Your balance is $1000. |");

puts("| Press any key |");

puts("================================");

getch();

break;

case '2':

do{

clrscr();

puts("==================================");

puts("| Please select Credit money: |");

puts("| 1. $50 |");

puts("| 2. $100 |");

puts("| 3. Return |");

puts("==================================");

CreditMoney = getch();

}while( CreditMoney!='1' && CreditMoney!='2' && CreditMoney!='3' );

switch(CreditMoney)