黑龙江七鳃鳗养殖:C程序源代码(3)

来源:百度文库 编辑:中财网 时间:2024/04/18 17:47:22
151 找出其中有不及格课程的学生及学号
main()
{float score[][4]={{60,70,80,90},{56,89,67,88},{34,78,80,66}};
float *search(float(*pointer)[4]);
float *p;
int i,j;
for(i=0;i<3;i++)
{p=search(score+i);
if(p==*(score+i))
{printf("No.%d scores:",i);
for(j=0;j<4;j++)
printf("%10.2f",*(p+j));
printf("\n");}
}
getch();
}
float *search(float(*pointer)[4])
{int i;
float *pt;
pt=*(pointer+1);
for(i=0;i<4;i++)
if(*(*pointer+i)<60)pt=*pointer;
return pt;
}
作者:问到你翻脸  2006-9-3 00:58回复此发言
152 将若干字符串按字母顺序(由小到大)输出~
#include "stdio.h"
#include "string.h"
char a[5][20];
void input(void)
{ int i;
for(i=0;i<5;i++)
{printf("input %dth word please:",i+1);
scanf("%s",a[i]);
}
}
void sort(void)
{ char *s;
int i,j;
s=(char *)malloc(20);
for(i=0;i<4;i++)
for(j=i+1;j<5;j++)
{ if (strcmp(a[i],a[j])>0)
{strcpy(s,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],s);}
}
free(s);
}
void print(void)
{
int i;
for(i=0;i<5;i++)
printf("%s\n",a[i]);
}
main()
{input();
sort();
print();
getch();
}
作者:问到你翻脸  2006-9-3 01:39回复此发言
153 将若干字符串按字母顺序(由小到大)输出~
#include 
#include 
main()
{void sort(char *name[],int n);
void print(char *name[],int n);
char *name[]={"follow me","basic","great wall","fortran","computer design"};
int n=5;
sort(name,n);
print(name,n);
getch();
}
void sort(char *name[],int n)
{char *temp;
int i,j,k;
for(i=0;i{k=i;
for(j=i+1;jif(strcmp(name[k],name[j])>0)k=j;
if(k!=i)
{temp=name[i];name[i]=name[k];name[k]=temp;}
}
}
void print(char *name[],int n)
{int i;
for(i=0;iprintf("%s\n",name[i]);
}
作者:问到你翻脸  2006-9-3 01:43回复此发言
154 指向指针的指针
main()
{char *name[]={"follow me","basic","great wall","fortran","computer design"};
char **p;
int i;
for(i=0;i<5;i++)
{p=name+i;
printf("%s\n",*p);
}
getch();
}
作者: 218.24.147.*  2006-9-3 13:08回复此发言
155 一个指针数组的元素指向整形数据
main()
{static int a[5]={1,3,5,7,9};
int *num[5]={&a[0],&a[1],&a[2],&a[3],&a[4]};
int **p,i;
p=num;
for(i=0;i<5;i++)
{printf("%d ",**p);p++;}
getch();
}
作者: 218.24.147.*  2006-9-3 13:27回复此发言
156 结构体变量的初始化
main()
{struct strdent
{long int num;
char name[20];
char sex;
char addr[20];
}
a={89031,"li lin",‘m‘,"123 beijing road"};
printf("NO.:%ld\nname:%s\nsex:%c\naddress:%s\n",a.num,a.name,a.sex,a.addr);
getch();
}
作者:问到你翻脸  2006-9-3 18:19回复此发言
157 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个
#include 
main()
{
char c;
int letter=0,space=0,digit=0,others=0;
printf("please input some characters\n");
while((c=getchar())!=‘\n‘)
{if(c>=‘a‘&&c<=‘z‘||c>=‘A‘&&c<=‘Z‘)
letter++;
else if(c==‘ ‘)
space++;
else if(c>=‘0‘&&c<=‘9‘)
digit++;
else
others++;
}
printf("all in all:letter=%d space=%d digit=%d others=%d\n",letter,space,digit,others);
getch();
}
作者: 218.24.147.*  2006-9-3 20:23回复此发言
158 指向结构体变量的指针
#include 
main()
{struct student
{long num;
char name[20];
char sex;
float score;
};
struct student stu_1;
struct student *p;
p=&stu_1;
stu_1.num=89101;
strcpy(stu_1.name,"li lin");
stu_1.sex=‘m‘;
stu_1.score=89.5;
printf("NO.:%ld\nname:%s\nsex:%c\nscore:%f\n",stu_1.num,stu_1.name,stu_1.sex,stu_1.score);
printf("NO.:%ld\nname:%s\nsex:%c\nscore:%f\n",(*p).num,(*p).name,(*p).sex,(*p).score);
getch();
}
作者:问到你翻脸  2006-9-3 20:44回复此发言
159 对候选人得票的统计程序,设有3个候选人,每次输入一个得票的候选
#include 
struct person
{char name[20];
int count;}leader[3]={"li",0,"zhang",0,"fun",0};
main()
{int i,j;
char leader_name[20];
for(i=1;i<=10;i++)
{scanf("%s",leader_name);
for(j=0;j<3;j++)
if(strcmp(leader_name,leader[j].name)==0)leader[j].count++;
}
printf("\n");
for(i=0;i<3;i++)
printf("%5s:%d\n",leader[i].name,leader[i].count);
getch();
}
作者:问到你翻脸  2006-9-3 21:02回复此发言
160 指向结构体数组的指针的应用
struct student
{int num;
char name[20];
char sex;
int age;
};
struct student stu[3]={{10101,"li lin",‘m‘,18},{10102,"zhang fun",‘m‘,19},{10104,"wang min",‘f‘,20}};
main()
{struct student *p;
printf("NO. name sex age\n");
for(p=stu;pprintf("%5d%-20s%2c%4d\n",p->num,p->name,p->sex,p->age);
getch();
}
作者:问到你翻脸  2006-9-3 21:46回复此发言
161 结构体变量的指针做形参
#define FORMAT "%d\n%s\n%f\n%f\n%f\n"
struct student
{int num;
char name[20];
float score[3];
}stu={12345,"lili",67.5,89,78.6};
main()
{void print(struct student *);
print(&stu);
}
void print(struct student *p)
{printf(FORMAT,p->num,p->name,p->score[0],p->score[1],p->score[2]);
printf("\n");
getch();
}
作者:问到你翻脸  2006-9-3 22:22回复此发言
162 一个简单的链表程序
#define NULL 0
struct student
{long num;
float score;
struct student *next;
};
main()
{struct student a,b,c,*head,*p;
a.num=99101;a.score=89.5;
b.num=99103;b.score=90;
c.num=99107;c.score=85;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{printf("%ld%5.1f\n",p->num,p->score);
p=p->next;
}
while(p!=NULL);
getch();
}
作者:问到你翻脸  2006-9-4 01:30回复此发言
163 两个乒乓球队进行比赛,各出三人。
main()
{char i,j,k;
for(i=‘x‘;i<=‘z‘;i++)
for(j=‘x‘;j<=‘z‘;j++)
{if(i!=j)
for(k=‘x‘;k<=‘z‘;k++)
{if(i!=k&&j!=k)
{if(i!=‘x‘&&k!=‘x‘&&k!=‘z‘)
printf("order is a--%c\tb--%c\tc--%c\n",i,j,k);
}}}
getch();}
作者:问到你翻脸  2006-9-4 14:59回复此发言
164 输出菱形图案
main()
{int i,j,k;
for(i=0;i<=3;i++)
{
for(j=0;j<=2-i;j++)
printf(" ");
for(k=0;k<=2*i;k++)
printf("*");
printf("\n");
}
for(i=0;i<=2;i++)
{
for(j=0;j<=i;j++)
printf(" ");
for(k=0;k<=4-2*i;k++)
printf("*");
printf("\n");
}
getch();
}
作者:问到你翻脸  2006-9-4 15:07回复此发言
165 有一分数序列:2/1,3/2,5/3,8/5求这个数列的前20项之和
main()
{
int n,t,number=20;
float a=2,b=1,s=0;
for(n=1;n<=number;n++)
{s=s+a/b;
t=a;a=a+b;b=t;
}
printf("sum is %9.6f\n",s);
getch();
}
作者:问到你翻脸  2006-9-4 15:34回复此发言
166 求1+2!+3!..+20!的和
main()
{
float n,s=0,t=1;
for(n=1;n<=3;n++)
{ t*=n;
s+=t;
}
printf("1+2!+3!...+20!=%e\n",s);
getch();
}
作者:问到你翻脸  2006-9-4 16:32回复此发言
167 输入5个字符,倒序输出
#include"stdio.h"
main()
{int i=5;
void palin(int n);
printf("\40:");
palin(i);
printf("\n");
getch();
}
void palin(n)
int n;
{
char next;
if(n<=1)
{next=getchar();
printf("\n\0:");
putchar(next);
}
else
{next=getchar();
palin(n-1);
putchar(next);
}
}
作者:c语言专用  2006-9-4 17:07回复此发言
168 有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个
age(n)
int n;
{
int c;
if(n==1)c=10;
else c=age(n-1)+2;
return c;
}
main()
{printf("%d",age(5));
getch();
}
作者:c语言专用  2006-9-4 23:46回复此发言
169 给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印
main()
{
long a,b,c,d,e,x;
scanf("%ld",&x);
a=x/10000;
b=x%10000/1000;
c=x%1000/100;
d=x%100/10;
e=x%10;
if(a!=0)printf("there are 5,%ld %ld %ld %ld %ld\n",e,d,c,b,a);
else if(b!=0)printf("there are 4,%ld %ld %ld %ld\n",e,d,c,b);
else if(c!=0)printf("there are 3,%ld %ld %ld\n",e,d,c);
else if(d!=0)printf("there are 2,%ld %ld\n",e,d);
else if(e!=0)printf("there are 1,%ld\n",e);
getch();
}
作者:c语言专用  2006-9-5 00:26回复此发言
170 输入一个5位数,判断他是否为回文数
main()
{
long ge,shi,qian,wan,x;
scanf("%ld",&x);
wan=x/10000;
qian=x%10000/1000;
shi=x%100/10;
ge=x%10;
if(ge==wan&&shi==qian)
printf("this number is a huiwen\n");
else
printf("this number is not a huiwen\n");
getch();
}
作者:问到你翻脸  2006-9-5 23:29回复此发言
171 请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样
#include 
void main()
{
char letter;
printf("please input the first letter of someday\n");
while((letter=getch())!=‘Y‘)
{switch(letter)
{case ‘s‘:printf("please input second letter\n");
if((letter=getch())==‘a‘)
printf("saturday\n");
else if((letter=getch())==‘u‘)
printf("sunday\n");
else printf("data error\n");
break;
case ‘f‘:printf("friday\n");break;
case ‘m‘:printf("monday\n");break;
case ‘t‘:printf("please input second letter\n");
if((letter=getch())==‘u‘)
printf("tuesday\n");
else if((letter=getch())==‘h‘)
printf("thursday\n");
else printf("data error\n");
break;
case ‘w‘:printf("wednesday\n");break;
default:printf("data error\n");
}}}
作者: 218.24.147.*  2006-9-6 00:55回复此发言
172 改变字体颜色和背景颜色
#include 
#include 
int main(void)
{
window(10,10,40,11);
textcolor(RED);
textbackground(GREEN);
cprintf("this is a test");
system("PAUSE");
return 0;
}
作者: 218.24.147.*  2006-9-6 16:43回复此发言
173 #ifdef NUM,#else ,#endif free(ps)
#define NUM ok
main()
{struct stu
{int num;
char *name;
char sex;
float score;
} *ps;
ps=(struct stu*)malloc(sizeof(struct stu));
ps->num=102;
ps->name="zhang ping";
ps->sex=‘m‘;
ps->score=62.5;
#ifdef NUM
printf("Number=%d\nScore=%f\n",ps->num,ps->score);
#else
printf("Name=%s\nSex=%c\n",ps->name,ps->sex);
#endif
free(ps);
getch();
}
作者: 218.24.147.*  2006-9-6 22:34回复此发言
174 #if ,#else,#endif的用法
#define R 1
main()
{float c,r,s;
printf("input a number:");
scanf("%f",&c);
#if R
r=3.14159*c*c;
printf("area of round is:%f\n",r);
#else
s=c*c;
printf("area of square is:%f\n",s);
#endif
getch();
}
作者: 218.24.147.*  2006-9-6 22:42回复此发言
175 随机数的生成
#include
#include
#include
main()
{
int i,integers;
srand(time(NULL));
printf("\t\tandom integers you want!\n");
for(i=1;i<=9;i++)
{integers=1+(rand()%9);
printf("%-5d",integers);
}
getch();
}
作者: 218.24.147.*  2006-9-7 04:07回复此发言
176 打印3角形
main()
{int i,j,n;
scanf("%d",&n);
for(i=0;i{
for(j=0;j<2*n-2;j++)
{ if((j!=n-1-i)&&(j!=n-1+i))
printf(" ");
else
printf("*");
}
printf("\n");
}
for(i=0;i<2*n-1;i++) printf("*");
getch();
}
作者:c语言专用  2006-9-7 14:41回复此发言
177 学习gotoxy()与clrscr()函数
#include 
void main(void)
{
clrscr();
textbackground(2);
gotoxy(1,5);
cprintf("Output at row 5 column 1\n");
textbackground(4);
gotoxy(20,10);
cprintf("Output at row 10 column 20\n");
getch();
}
作者:c语言专用  2006-9-7 14:56回复此发言
178 文本颜色设置
#include 
void main()
{
int color;
for(color=1;color<16;color++)
{
textcolor(color);
cprintf("this is color %d\r\n",color);
}
textcolor(128+15);
cprintf("this is blinking\r\n");
getch();}
作者:c语言专用  2006-9-7 15:11回复此发言
179 对10个数进行排序由小到大输出
对10个数进行排序由小到大输出
#define N 10
main()
{
int i,j,min,tem,a[N];
printf("please input ten num:\n");
for(i=0;i{printf("a[%d]=",i);
scanf("%d",&a[i]);}
printf("\n");
for(i=0;iprintf("%5d",a[i]);
printf("\n");
for(i=0;i{min=i;
for(j=i+1;jif(a[min]>a[j])min=j;
tem=a[i];
a[i]=a[min];
a[min]=tem;
}
printf("after sorted\n");
for(i=0;iprintf("%5d",a[i]);
getch();
}
作者:c语言专用  2006-9-7 15:32回复此发言
180 输出对角线
main()
{
int a[3][3],sum=0;
int i,j;
printf("please input rectangle element:\n");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
for(i=0;i<3;i++)
sum=sum+a[i][i];
printf("duijiaoxian he is %d",sum);
getch();
}
作者:c语言专用  2006-9-7 18:17回复此发言
181 有一个已经排好序的数组。现输入一个数,要求按原来的规律将它插入
main()
{
int a[11]={1,4,6,9,13,16,19,28,40,100};
int temp1,temp2,number,end,i,j;
printf("original array is :\n");
for(i=0;i<10;i++)
printf("%5d",a[i]);
printf("\n");
printf("insert a new number:");
scanf("%d",&number);
end=a[9];
if(number>end)
a[10]=number;
else
{for(i=0;i<10;i++)
{if(a[i]>number)
{temp1=a[i];
a[i]=number;
for(j=i+1;j<11;j++)
{temp2=a[j];
a[j]=temp1;
temp1=temp2;
}
break;
}
}
}
for(i=0;i<11;i++)
printf("%6d",a[i]);
getch();
}
作者:问到你翻脸  2006-9-7 20:28回复此发言
182 静态数组的应用
#include 
varfunc()
{
int var=0;
static int static_var=0;
printf("\40:var equal %d \n",var);
printf("\40:static var equal %d \n",static_var);
printf("\n");
var++;
static_var++;
}
void main()
{int i;
for(i=0;i<3;i++)
varfunc();
getch();
}
作者: 218.24.147.*  2006-9-8 19:37回复此发言
183 学习使用auto定义变量的用法
#include "stdio.h"
main()
{int i,num;
num=2;
for(i=0;i<3;i++)
{
printf("\40:the num equal %d \n",num);
num++;
{
auto int num=1;
printf("\40: the internal block num equal %d \n",num);
num++;
}}
getch();}
作者: 218.24.147.*  2006-9-8 19:49回复此发言
184 学习使用static的另一用法。
#include 
main()
{
int i,num;
num=2;
for(i=0;i<3;i++)
{
printf("\40:the num equal %d \n",num);
num++;
{
static int num=1;
printf("\40: the internal block num equal %d\n",num);
num++;
}}getch();}
作者: 218.24.147.*  2006-9-8 19:57回复此发言
185 学习使用external的用法。
#include "stdio.h"
int a,b,c;
void add()
{int a;
a=3;
c=a+b;
}
void main()
{a=b=4;
add();
printf("the value of c is equal to %d\n",c);
getch();
}
作者: 218.24.147.*  2006-9-8 20:00回复此发言
186 学习使用register定义变量的方法。
void main()
{register int i;
int tmp=0;
for(i=1;i<=100;i++)
tmp+=i;
printf("the sum is %d\n",tmp);
getch();
}
作者: 218.24.147.*  2006-9-8 20:03回复此发言
187 宏#define命令练习(1)
#include "stdio.h"
#define TRUE 1
#define FALSE 0
#define SQ(x) (x)*(x)
void main()
{
int num;
int again=1;
printf("\40:program will stop if input value less than 50.\n");
while(again)
{
printf("\40:please input number==>");
scanf("%d",&num);
printf("\40:the square for this number is %d\n",SQ(num));
if(num>=50)
again=TRUE;
else
again=FALSE;
}getch();
}
作者: 218.24.147.*  2006-9-8 20:11回复此发言
188 宏#define命令练习(2)
#include "stdio.h"
#define exchange(a,b) {int t; \
t=a; \
a=b;\
b=t;}
void main(void)
{
int x=10;
int y=20;
printf("x=%d; y=%d\n",x,y);
exchange(x,y);
printf("x=%d; y=%d\n",x,y);
getch();
}
作者: 218.24.147.*  2006-9-8 21:08回复此发言
189 宏#define命令练习(3)
宏#define命令练习(3)
#define LAG >
#define SMA <
#define EQ ==
#include "stdio.h"
void main()
{
int i=10;
int j=20;
if(i LAG j)
printf("\40:%d larger than %d\n",i,j);
else if(i EQ j)
printf("\40:%d equal to %d \n",i,j);
else if(i SMA j)
printf("\40:%d smaller than %d\n",i,j);
else
printf("\40: No such value.\n");
getch();
}
作者: 218.24.147.*  2006-9-9 00:23回复此发言
190 学习使用按位与 & 。
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a&3;
printf("\40; the a &b(decimal) is %d\n",b);
b&=7;
printf("\40: the a &b(decimal) is %d\n",b);
getch();
}
作者: 218.24.147.*  2006-9-9 02:21回复此发言
191 学习使用按位或 | 。
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a|3;
printf("\40: the a &b(decimal) is %d\n",b);
b|=7;
printf("\40: the a & b(decimal) is %d\n",b);
getch();}
作者: 218.24.147.*  2006-9-9 02:27回复此发言
192 学习使用按位异或 ^ 。
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a^3;
printf("\40: the a & b(decimal) is %d \n",b);
b^=7;
printf("\40: the a & b(decimal) is %d \n",b);
getch();
}
作者: 218.24.147.*  2006-9-9 02:31回复此发言
193 题目:取一个整数a从右端开始的4~7位。
main()
{
unsigned a,b,c,d;
scanf("%o",&a);
b=a>>4;
c=~(~0<<4);
d=b&c;
printf("%o\n%o\n",a,d);
getch();
}
作者: 218.24.147.*  2006-9-9 21:47回复此发言
194 学习使用按位取反~。
#include "stdio.h"
main()
{
int a,b;
a=234;
b=~a;
printf("\40:the a‘s 1 complement(decimal) is %d \n",b);
a=~a;
printf("\40: the a‘s 1 complement(hexidecimal) is %x \n",a);
getch();
}
作者: 218.24.147.*  2006-9-10 16:40回复此发言
195 画图,学用circle画圆形
#include "graphics.h"
main()
{
int driver,mode,i;
float j=1,k=1;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
for(i=0;i<=25;i++)
{
setcolor(8);
circle(310,250,k);
k=k+j;
j=j+0.3;
}
getch();
}
作者: 218.24.147.*  2006-9-10 16:51回复此发言
196 画图,学用line画直线。
#include 
main()
{int driver,mode,i;
float x0,y0,y1,x1;
float j=12,k;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(GREEN);
x0=263;y0=263;y1=275;x1=275;
for(i=0;i<=18;i++)
{
setcolor(6);
line(x0,y0,x0,y1);
x0=x0-5;
y0=y0-5;
x1=x1+5;
y1=y1+5;
j=j+10;
}
x0=263;y1=275;y0=263;
for(i=0;i<=20;i++)
{
setcolor(5);
line(x0,y0,x0,y1);
x0=x0+5;
y0=y0+5;
y1=y1-5;
}
getch();
}
作者: 218.24.147.*  2006-9-11 08:11回复此发言
197 画图,学用rectangle画方形
#include "graphics.h"
main()
{
int x0,y0,y1,x1,driver,mode ,i;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
x0=263;y0=263;y1=275;x1=275;
for(i=0;i<=18;i++)
{
setcolor(1);
rectangle(x0,y0,x1,y1);
x0=x0-5;
y0=y0-5;
x1=x1+5;
y1=y1+5;
}
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(150,40,"how beautiful it is!");
line(130,60,480,60);
setcolor(2);
circle(269,269,137);
getch();
}
作者: 218.24.147.*  2006-9-11 08:25回复此发言
198 图画综合例子
#define PAI 3.1415926
#define B 0.809
#include "graphics.h"
#include "math.h"
main()
{
int i,j,k,x0,y0,x,y,driver,mode;
float a;
driver=CGA;mode=CGAC0;
initgraph(&driver,&mode,"");
setcolor(3);
setbkcolor(GREEN);
x0=150;y0=100;
circle(x0,y0,10);
circle(x0,y0,20);
circle(x0,y0,50);
for(i=0;i<16;i++)
{
a=(a*PAI/16)*i;
x=ceil(x0+48*cos(a));
y=ceil(y0+48*sin(a)*B);
setcolor(2);
line(x0,y0,x,y);
}
setcolor(3);
circle(x0,y0,60);
settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
outtextxy(10,170,"press a key");
getch();
setfillstyle(HATCH_FILL,YELLOW);
floodfill(202,100,WHITE);
getch();
for(k=0;k<=500;k++)
{
setcolor(3);
for(i=0;i<=16;i++)
{
a=(2*PAI/16)*i+(2*PAI/180)*k;
x=ceil(x0+48*cos(a));
y=ceil(y0+48+sin(a)*B);
setcolor(2);
line(x0,y0,x,y);
}
for(j=1;j<=50;j++)
{
a=(2*PAI/16)*i+(2*PAI/180)*k-1;
x=ceil(x0+48*cos(a));
y=ceil(y0+48*sin(a)*B);
line(x0,y0,x,y);
}
}
restorecrtmode();
}
作者: 218.24.147.*  2006-9-11 08:48回复此发言
199 图画综合例子
#include "graphics.h"
#define LEFT 0
#define TOP 0
#define RIGHT 639
#define BOTTOM 479
#define LINES 400
#define MAXCOLOR 15
main()
{
int driver,mode,error;
int x1,y1;
int x2,y2;
int dx1,dy1,dx2,dy2,i=1;
int count=0;
int color=0;
driver=VGA;
mode=VGAHI;
initgraph(&driver,&mode,"");
x1=x2=y1=y2=10;
dx1=dy1=2;
dx2=dy2=3;
while(!kbhit())
{
line(x1,y1,x2,y2);
x1+=dx1;y1+=dy1;
x2+=dx2;y2+=dy2;
if(x1<=LEFT||x1>=RIGHT)
dx1=dx1;
if(y1<=TOP||y1>=BOTTOM)
dy1=dy1;
if(x2<=LEFT||x2>=RIGHT)
dx2=dx2;
if(y2<=TOP||y2>=BOTTOM)
dy2=dy2;
if(++count>LINES)
{
setcolor(color);
color=(color>=MAXCOLOR)?0:++color;
}
}
closegraph();
}
作者: 218.24.147.*  2006-9-11 09:00回复此发言
200 打印出杨辉三角形(要求打印出10行如下图)
#include "stdio.h"
main()
{
int i,j;
int a[10][10];
printf("\n");
for(i=0;i<10;i++)
{
a[i][0]=1;
a[i][i]=1;
}
for(i=2;i<10;i++)
for(j=1;ja[i][j]=a[i-1][j-1]+a[i-1][j];
for(i=0;i<10;i++)
{
for(j=0;j<=i;j++)
{
printf("%5d",a[i][j]);
if(j==i)
printf("\n");
}
}
getch();
}