标题:我想知道哪里出错了---关于以数组为参数的函数
只看楼主
默默的默默
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-3-17
结帖率:0
已结贴  问题点数:20 回复次数:1 
我想知道哪里出错了---关于以数组为参数的函数
#include<graphics.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>


#include <conio.h>

int a[100],b[100],c[100];
void putstar()
{
  int i,dotx,doty,w,h,t;
  w=getmaxx();
  h=350;
  for(i=0;i<100;i++)
  {
    dotx=rand()%(w-1);
    a[i]=dotx;
    doty=rand()%(h-1);
    b[i]=doty;
    t=rand()%(3);
    c[i]=t;
    setfillcolor(WHITE);
    fillcircle(dotx,doty,t);
  }
}
void revertstar(int a[],int b[],int c[])
{
  int i;
  for(i=0;i<100;i++)
  {
    setfillcolor(WHITE);
    fillcircle(a[i],b[i],c[i]);
  }
}

void main()
{
    initgraph(640, 480);
   
    int x = 320,y=240;
setfillcolor(LIGHTBLUE);
bar(0, 0,640,480);
setfillcolor(GREEN);
bar(0, 350,640,480);

putstar();
   
    // 画初始图形
    setlinecolor(YELLOW);
    setfillcolor(YELLOW);
    fillcircle(x, y, 30);

   
    char c;
    while(c != 27)
    {
        // 获取按键
        c = getch();
        
        // 先擦掉上次显示的旧图形
        setlinecolor(BLACK);
        setfillcolor(BLACK);
        fillcircle(x, y, 50);
        
        // 根据输入,计算新的坐标
        switch(c)
        {
            case 75: x-=2; break;
            case 77: x+=2; break;
            case 72: y-=2; break;
            case 80: y+=2; break;
            case 27: break;
        }
        
        // 绘制新的图形
        setlinecolor(YELLOW);
        setfillcolor(YELLOW);
        fillcircle(x, y, 50);
        revertstar(a,b,c);
        
        // 延时
        Sleep(10);
    }
   
    closegraph();
}
搜索更多相关主题的帖子: include 
2014-03-17 22:36
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:20 
变量重名

此程序过期无实用价值

DO IT YOURSELF !
2014-03-18 05:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-428692-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.148473 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved