當前位置:首頁 » 編程語言 » c語言畫球鏈

c語言畫球鏈

發布時間: 2023-02-11 09:08:37

c語言 項鏈問題

你問的是 任意一串 左右去顏色 取出來的同顏色顏色相加的話 那不就是 原來的兩種珠子的綜合嗎?這樣的話無論從哪裡斷開 m 就是等於 任意給定的另個顏色珠子綜合之差了。你的意思 不明白

⑵ 如何用C語言編程一個滾動的小球 最好是五彩的 滾動的

#include"graphics.h"
#include"stdlib.h"
main()
{
int i,gdriver,gmode,size,*buf;
gdriver=DETECT;
initgraph(&gdriver,&gmode," ");
setbkcolor(BLACK);
cleardevice();
setcolor(LIGHTRED);
setlinestyle(0,0,1);
setfillstyle(1,4);
circle(100,200,20);
floodfill(100,200,12);
size=imagesize(79,159,131,231);
buf=malloc(size);
getimage(79,159,131,231,buf);
putimage(530,269,buf,COPY_PUT);
getch();
for(i=0;i<200;i++)
{
putimage(75+i,160,buf,COPY_PUT);
putimage(515-i,160,buf,COPY_PUT);
}
for(i=0;i<200; i++)
{
putimage(270-i,160,buf,COPY_PUT);
putimage(320+i,160,buf,COPY_PUT);
}
getch();
closegraph();
}

⑶ 怎麼用c語言畫出一個隨時間變化的圓形

  1. circle函數是TURBO C提供的圖形介面,用來畫圓。不屬於標准庫函數,不具備可移植性。
    函數名:circle
    功 能: 在給定半徑以(x, y)為圓心畫圓
    用 法:void far circle(int x, int y, int radius)

  2. 隨時間變化,可以用cleardevice函數清除屏幕,不斷畫半徑不同的圓。看起來就像是一個隨時間變化的圓形。

    函數名: cleardevice
    功 能: 清除圖形屏幕
    用 法: void far cleardevice(void);
    常式:

    #include<graphics.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<conio.h>
    intmain(void)
    {
    /*requestautodetection*/
    intgdriver=DETECT,gmode,errorcode;
    intmidx,midy;
    intradius=100;
    /**/
    initgraph(&gdriver,&gmode,"");
    /*readresultofinitialization*/
    errorcode=graphresult();
    if(errorcode!=grOk)/*anerroroccurred*/
    {
    printf("Graphicserror:%s ",grapherrormsg(errorcode));
    printf("Pressanykeytohalt:");
    getch();
    exit(1);/*terminatewithanerrorcode*/
    }
    midx=getmaxx()/2;
    midy=getmaxy()/2;
    setcolor(getmaxcolor());
    for(i=0;i<1000000;i++)if(i%50000==0){
    cleardevice();/*cleanthescreen*/
    circle(midx,midy,radius--);/*drawthecircle*/
    }
    getch();
    closegraph();
    return0;
    }

⑷ c語言中.用4種顏色畫8個球,要求每個球的顏色隨機選擇的程序怎麼寫

4種顏色 的RGB 數值存放在 unsigned int color[4] 里。
用 rand()%4 定出 color[ ] 的下標 ( 0,1,2,3 之一)

#include <stdio.h>
#include <time.h>

main(){
unsigned int color[4]={0xff00a0,0x00ff80,0x8040ff,0xff8000};
int i;
srand(time(NULL)); // 隨機種子
for (i=0;i<8;i++)
{
printf("draw Ball_%d in color %06x\n",i,color[rand()%4]);
}

return 0;
}

⑸ 如何用C語言編寫一個鏈表

#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"

struct Node
{
int data;//數據域
struct Node * next;//指針域
};

/*************************************************************************************
*函數名稱:Create
*函數功能:創建鏈表.
*輸入:各節點的data
*返回值:指針head
*************************************************************************************/
struct Node * Create()
{
struct Node *head,*p1,*p2;
head = NULL;
p1 = p2 = (struct Node *)malloc(sizeof(struct Node));
printf("Input the linklist (Input 0 to stop):\n");
scanf("%d",&p1->data);
while(p1->data!=0)
{
if(head == NULL){
head = p1;
}else{
p2->next = p1;
p2 =p1;
}
p1 = (struct Node *)malloc(sizeof(struct Node));
scanf("%d",&p1->data);
}
p2->next = NULL;
return head;
}
/*************************************************************************************
*函數名稱:insert
*函數功能:在鏈表中插入元素.
*輸入:head 鏈表頭指針,p新元素插入位置,x 新元素中的數據域內容
*返回值:無
*************************************************************************************/
void insert(struct Node * head,int p,int x)
{
struct Node * tmp = head;
struct Node * tmp2 ;
int i ;
for(i = 0;i<p;i++)
{
if(tmp == NULL)
return ;
if(i<p-1)
tmp = tmp->next;
}
tmp2 = (struct Node *)malloc(sizeof(struct Node));
tmp2->data = x;
tmp2->next = tmp->next;
tmp->next = tmp2;
}
/**************************************************************************************
*函數名稱:del
*函數功能:刪除鏈表中的元素
*輸入:head 鏈表頭指針,p 被刪除元素位置
*返回值:被刪除元素中的數據域.如果刪除失敗返回-1
**************************************************************************************/
int del(struct Node * head,int p)
{
struct Node * tmp = head;
int ret , i;
for(i = 0;i<p;i++)
{
if(tmp == NULL)
return -1;
if(i<p-1)
tmp = tmp->next;
}
ret = tmp->next->data;
tmp->next = tmp->next->next;
return ret;
}
/**************************************************************************************
*函數名稱:print
*函數功能:列印鏈表中的元素
*輸入:head 鏈表頭指針
*返回值:無
**************************************************************************************/
void print(struct Node *head)
{
struct Node *tmp;
for(tmp = head; tmp!=NULL; tmp = tmp->next)
printf("%d ",tmp->data);
printf("\n");
}
/**************************************************************************************
*函數名稱:main
*函數功能:主函數創建鏈表並列印鏈表。
**************************************************************************************/
int main(){
struct Node * head = Create();
print(head);
return 0;
}

⑹ 用c語言應該怎樣寫小球沿著任意一條直線運動求詳解

想繪制一個沿直線運動的小球嗎?
繪制圖形可以用GDI,按照執行運動直接用直線公式就好了,然後x取值從0到屏幕寬度,然後一個循環,記得要Sleep啊。

⑺ C語言球類問題

這就是個找第K小值的問題吧,因為質量相同碰撞後只是交換速度而已,所以你可以理解為它們是互相穿過了(量子態超相乾的2333),找到初始數據中第K小的,然後加上at就行了吧

⑻ c語言 鏈表流程圖 怎麼畫呀

你一步步往下分,流程圖不就出來了,比如你的例子:
首先就是p1->number,即p1指向的結點
分不等於0,小於0,等於0 三種情況,

然後再往下分,比如p1->number!=0時
=>n=n+1
判斷n
如果為真怎麼樣,為假又怎麼樣(繼續走)。。。。

就是麻煩點,一步步來流程圖就出來。不過。。。這種東西用流程圖表示,太麻煩了吧。。。

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:583
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:877
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:572
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:758
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:674
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1001
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:245
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:104
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:796
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:702