⑴ 请帮忙看一下下面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='