⑴ 請幫忙看一下下面c語言的程序,,讓它可以直接在Turboc2.0中實現禮花綻放的動畫效果,謝謝!
C程序怎麼也得有個主函數吧,否則怎麼運行?
⑵ C語言放鞭炮問題,急哦!~
設t=0時刻,五個人第一次放,
則t=5秒時,A第二次放;t=10秒時,B第二次放...
程序的思路是
用一個數組temp[]來存放所有不同的時間;
首先把A放鞭炮的時間,存入temp[]里,
然後把B放鞭炮的時間,逐個與temp[]里的所有值作比較,如果b[j]與temp[]里的所有值都不同,那麼就將b[j]增加到temp[]里,並且總數加1;
然後C、D、E放鞭炮的時間也與B作同樣處理。
程序如下:
結果算得放的鞭炮的響聲總數=110
#include<stdio.h>
main()
{
int i,j,p,total=30;
int b[30],c[30],d[30],e[30],temp[120];
for(i=0;i<30;i++)
{temp[i]=i*5;b[i]=i*10;c[i]=i*13;
d[i]=i*15;e[i]=i*16;
}
for(j=1;j<30;j++)
{
p=1;
for(i=0;i<total;i++)
if(b[j]==temp[i]) {p=0;break;}
if(p) {temp[total]=b[j];total++;}
}
for(j=1;j<30;j++)
{
p=1;
for(i=0;i<total;i++)
if(c[j]==temp[i]) {p=0;break;}
if(p) {temp[total]=c[j];total++;}
}
for(j=1;j<30;j++)
{
p=1;
for(i=0;i<total;i++)
if(d[j]==temp[i]) {p=0;break;}
if(p) {temp[total]=d[j];total++;}
}
for(j=1;j<30;j++)
{
p=1;
for(i=0;i<total;i++)
if(e[j]==temp[i]) {p=0;break;}
if(p) {temp[total]=e[j];total++;}
}
printf("the total is %d\n",total);
for(i=0;i<total;i++) printf("%3d ",temp[i]);
printf("\n");
}
⑶ 模擬煙花的程序,運行總出錯,請c語言大師指點!!!
選項->目錄->輸出目錄->不要設置和initgraph(&dr,&mode,"d:\\turboc2"); 一樣就可以正常執行.
Options->Directories->Output Directory->不要設置和initgraph(&dr,&mode,"d:\\turboc2"); 一樣就可以正常執行.
⑷ c語言中,甲、乙、丙、丁四人同時開始放鞭炮問題
1)i表示的是所用掉的時間,就是說用時間的形參,t表示時間間隔,就是上面的t1,t2的形參。ok()函數是判斷在i這個時間點,時間間隔為t的人,放不放。
2)
if(OK(t, t1, n) || OK(t, t2, n)|| OK(t, t3, n) || OK(t, t4, n) )
count++;
這段代碼是表示當上面這些至少有一個成立,就是人放時,count++;count是所聽到的次數。
⑸ 求程序詳解 這是一個 在tc下運行的c語言動畫程序 綻放的禮花
學編程不能這樣學的,就算解釋清楚了每一步,要想看懂整個程序也是有很大困難的。還是一步步扎實的學吧。
再者,看程序應該是 tc2.0 的,先換一個好用點的編譯器吧,比如 vc6,事半功倍。
⑹ C語言設計跑馬燈程序
#include<reg51.h> //51系列單片機定義文件
#define uchar unsigned char //定義無符號字元
#define uint unsigned int //定義無符號整數
void delay(uint); //聲明延時函數
void main(void)
{
uint i;
uchar temp;
while(1)
{
temp=0x01;
for(i=0;i<8;i++) //8個流水燈逐個閃動
{
P1=~temp;
delay(100); //調用延時函數
temp<<=1;
}
}
void delay(uint t) //定義延時函數
{
register uint bt;
for(;t;t--)
for(bt=0;bt<255;bt++);
}
跑馬燈程序最基本的,c語言還未入門啊!!!
⑺ C語言簡單冒泡法程序
#include<stdio.h>
voidsort(int*a,intlen)
{inti=0;
intj;
intt;
for(i=0;i<len;i++)
{
for(j=0;j<len-i-1;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
}
intmain(intargc,char*argv[])
{
inta[10]={
-999,2,3,77,12,88,0,-8,99,100
};
inti=0;
sort(a,10);
for(i=0;i<10;i++)
{
printf("%d",a[i]);
}
return0;
}
(7)c語言放煙花程序擴展閱讀
冒泡排序法
#include"stdio.h"
voidmain()
{
inta[10];
inti,j,temp;
//輸入10個整型數據
printf("Pleaseinputtennumbers: ");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
//排序
for(i=0;i<9;i++)//10個數,10-1輪冒泡,每一輪都將當前最大的數推到最後
{
for(j=0;j<9-i;j++)//9-i,意思是每當經過一輪冒泡後,就減少一次比較
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
//列印排序結果
for(i=0;i<10;i++)
printf("%d ",a[i]);
return0;
}
⑻ 用C語言設計屏幕界面程序!
呵呵 我有哦 今天剛編了一個 是一個運動的羽毛球拍
然後是在寫漢字 是一筆一畫寫的哦 在寫「我愛你」這三個字
現在還不想分享 我送給了女朋友
你要的話加我QQ
還有一個是煙花的程序
可以現場給你 挺簡單的
#include "slib.h"
#include"graphics.h"
yanhua()
{int gd=DETECT,gr,a[8],b[8],x,y,i,j,c;
initgraph(&gd,&gr,"");
randomize();
for(;!kbhit();)
{x=rand()P0 100; /*隨機中心坐標*/
y=rand()00 100;
a[0]=x; /*各點坐標的計算,我的煙花圖形沒能是圓的*/
b[0]=y-10;
a[1]=a[0] 5;
a[2]=a[1] 5;
a[3]=a[1];
a[4]=a[0];
a[5]=a[0]-5;
a[6]=a[5]-5;
a[7]=a[6] 5;
for(j=1;j<5;j )
b[j]=b[j-1] 5;
for(j=5;j<8;j )
b[j]=b[j-1]-5;
for(j=0;j<6;j ) /*煙花的大小設定*/
{
for(i=0;i<8;i )
{
c=rand() 1; /*各點的顏色隨機*/
setcolor(c);
circle(a[i],b[i],1);
}
delay(5000);
cleardevice();
b[0]-=10; /*各點的坐標變換*/
a[1] =5;
b[1]-=5;
a[2] =10;
a[3] =5;
b[3] =5;
b[4] =10;
a[5]-=5;
b[5] =5;
a[6]-=10;
a[7]-=5;
b[7]-=5;
}
}
getch();
closegraph();
}
main()
{while(1)
yanhua();
}
⑼ c語言放煙花代碼
#include "stdlib.h"
#include "graphics.h"
#include "stdio.h"
#include "math.h"
#include "conio.h "
#define PI 3.1425926
main()
{
int gdriver=DETECT,gmode,errorcode;
int a[10],b[10],x,y,c,r,i,j,t;
double rad = 0.0;
/* initialize graphics and local variables */
initgraph(&gdriver , &gmode ,"");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error : %s/n",grapherrormsg(errorcode));
printf("Please any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
randomize();
for(;!kbhit();)
{
x=rand()%500+100; /*隨機中心坐標*/
y=rand()%300+100;
for(r = 0 ;r <= 8 ; r++ ) /*煙花的大小設定*/
{
for(i = 0,rad = 0.0 ; rad < 2*PI; rad += 0.78 ) /*設定坐標*/
{
a[i++] = x + (int)r *10* cos(rad);
b[ i ] = y + (int)r *10* sin(rad);
}
t = i;
for(i=1;i<t;i++)
{
c=rand()%13+1; /*各點的顏色隨機*/
setcolor(c); /*功能:將當前圖形屏幕的當前筆畫顏色置為color.*/
circle(a[i],b[i],1);/* a[i],b[i] 為圓心 1 為半徑 畫圓 */
}
delay(10000);
delay(10000);
cleardevice();
函數名: cleardevice
功 能: 清除圖形屏幕
用 法: void far cleardevice(void);
}
}
getch();
closegraph();
函數名: closegraph
功 能: 關閉圖形系統
用 法: void far closegraph(void);
}
(9)c語言放煙花程序擴展閱讀
C語言:表白顯示(多彩小心心)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define I 20
#define R 340
#include <string.h>
int main()
{
char answer[10];
printf("遇到你 我才發現 曾經所有的條件 似乎都成了我等你的借口 ");
printf("我對你的感情已經決堤 所以 請允許我,從今往後映入你 明媚的眼 ");
printf("我 想和你 耳鬢廝磨,相濡以沫!");
printf("答應我吧! 輸入yes,你可以看到我的真心 ");
scanf("%s", answer);
float y, x, z, f;
for (y = 1.5f; y > -1.5f; y -= 0.1f)
{
for (x = -1.5f; x < 1.5f; x += 0.05f)
{
z = x * x + y * y - 1;
f = z * z*z - x * x*y*y*y;
putchar(f <= 0.0f ? "*********"[(int)(f*-8.0f)] : ' ');
}
putchar(' ');
}
long time;
for (;;)
{
system("color a");
for (time = 0; time<99999999; time++);
system("color b");
for (time = 0; time<99999999; time++);
system("color c");
for (time = 0; time<99999999; time++);
system("color d");
for (time = 0; time<99999999; time++);
system("color e");
for (time = 0; time<99999999; time++);
system("color f");
for (time = 0; time<99999999; time++);
system("color 0");
for (time = 0; time<99999999; time++);
system("color 1");
for (time = 0; time<99999999; time++);
system("color 2");
for (time = 0; time<99999999; time++);
system("color 3");
for (time = 0; time<99999999; time++);
system("color 4");
for (time = 0; time<99999999; time++);
system("color 5");
for (time = 0; time<99999999; time++);
system("color 6");
for (time = 0; time<99999999; time++);
system("color 7");
for (time = 0; time<99999999; time++);
system("color 8");
for (time = 0; time<99999999; time++);
system("color 9");
}
getchar();
return 0;
}
⑽ 用C語言編寫流星雨程序
數字流星雨代碼:
//流星雨.cpp:Defines the entry point for the console application.
//
///////////////////////////////////////////////////
//程序名稱:數字流星雨
//最後修改:2006-10-15
///////////////////////////////////////////////////
#include<windows.h>
#include<time.h>
#include<stdlib.h>
#include"graphics.h"
#include<conio.h>
#include<math.h>
/***********************宏定義**********************/
#define PI 3.1415926//圓周率
#define WIDTH 200//屏幕寬度,流星出生區域
#define HEIGHT 150//屏幕高度,流星出生區域
#define V 20//流星速度,單次移動的像素數
#define LENGTH 20//流星字元數
#define DELAY 30//延時
#define NUM 45//流星個數
/******************定義流星結構體*******************/
struct meteor
{
int x0;
int y0;
int yh;
char str[LENGTH];
}me[NUM]={0};
/*********************函數聲明**********************/
char AsciiRand();
void Move(char*p);
void InitMeteor(struct meteor*me);
int color(int y,int y0,int yh);
void Meteors(struct meteor me[]);
/***********************主函數**********************/
///int main(void)
int _tmain(int argc,_TCHAR*argv[]){
char c='