ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

ساعت ديجيتال و آنالوگ به زبان C

 
Post new topic   Reply to topic    ParsX.com Forum Index -> C/C++ Programming
View previous topic :: View next topic  
Author Message
monakiyani
مهمون يكي دو روزه


Joined: 27 Oct 2006
Posts: 3

PostPosted: Sun Oct 29, 2006 12:36 am    Post subject: ساعت ديجيتال و آنالوگ به زبان C Reply with quote

سلام.لطفا اگر كسي برنامه ساعت ديجيتال و آنالوگ به زبان C را دارد برام بفرسته و اگر نه لطفا
در مورد برنامه و گرافيكش توضيح بدين.با تشكر.
Back to top
arash
مدير بخش سي
مدير بخش سي


Joined: 27 Nov 2004
Posts: 1232
Location: www.parsx.com

PostPosted: Mon Oct 30, 2006 8:50 pm    Post subject: Reply with quote


//Programmed By : Himanshu Mishra
//Email ID : himanshu_mishra007@yahoo.co.in
/*Other Programmes: 1) SNAKEG
2) PIANO
*/

#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>

const float PI=3.141;

class needle
{
int size,color,x,y,end_x,end_y;
double theta;
public:
void draw(float,float);
void init(int a,int b,int c,int d)
{x=a;y=b;size=c;color=d;}
};
void needle::draw(float a,float b)
{
theta=(a*b-90)*(PI/180);
setcolor(0);
line(x,y,end_x,end_y);
setcolor(color);
end_x=x+cos(theta)*size;
end_y=y+sin(theta)*size;
line(x,y,end_x,end_y);
}
void main()
{
int d=DETECT,m;
initgraph(&d,&m,"c:\\tc\\bgi");
// setbkcolor(0);
int size=90,a;
float theta;
char tim[12][3]={"3","4","5","6","7","8","9","10","11","12","1","2"};
for(int i=0,j=0;i<360;i+=6)
{
theta=PI/180*i;
a=3;
if(i%5==0)
{
a=12;
outtextxy(320+cos(theta)*(size-a)-textwidth(tim[j])/2,240+sin(theta)*(size-a)-textheight(tim[j])/2,tim[j]);
j++;
a=8;
}
line(320+cos(theta)*(size-a),240+sin(theta)*(size-a),320+cos(theta)*size,240+sin(theta)*size);
}
circle(320,240,size+2);
circle(320,240,size+8);
setfillstyle(1,LIGHTBLUE);
floodfill(320,240+size+3,getcolor());
// setfillstyle(1,6);
// floodfill(0,0,getcolor());
outtext("Press any key to exit......");

needle second,minute,hour,milli;
second.init(320,240,60,BLUE);
minute.init(320,240,70,RED);
hour.init(320,240,40,LIGHTGRAY);
milli.init(320,240,65,6);

int sec,min,hr,hun,last_hun;
static char d_hr[3],d_min[3],d_sec[3],d_hun[3],time[20];
int d_x=275,d_y=120;
struct time t;
while(!kbhit())
{
gettime(&t);
hun=t.ti_hund;
sec=t.ti_sec;
min=t.ti_min;
hr=t.ti_hour;
if(hun!=last_hun)
{
//STARTING ANALOG CLOCK
setcolor(getbkcolor());
outtextxy(d_x,d_y,time);
setlinestyle(0,0,1);
milli.draw(hun,360/100);
second.draw(sec*100+hun,0.06);
setlinestyle(0,0,3);
minute.draw(min*60+sec,0.1);
hour.draw(hr*60+min,0.5);
//ENDING ANALOG CLOCK
//STARTING DIGITAL WATCH
itoa(hr,d_hr,10);
itoa(min,d_min,10);
itoa(sec,d_sec,10);
itoa(hun,d_hun,10);

time[0]=d_hr[0];
time[1]=d_hr[1];
time[2]=':';
time[3]=d_min[0];
time[4]=d_min[1];
time[5]=':';
time[6]=d_sec[0];
time[7]=d_sec[1];
time[8]='.';
time[9]=d_hun[0];
time[10]=d_hun[1];
for(int i=0;i<11;i++)
if(time[i]=='\0'){time[i]=time[i-1];time[i-1]='0';}
time[11]='\0';
setcolor(random(15));
outtextxy(d_x,d_y,time);
//ENDING DIGITAL WATCH
}
last_hun=hun;
}
closegraph();
}
Back to top
elinaz
مهمون يكي دو روزه


Joined: 21 Nov 2007
Posts: 42
Location: تهران

PostPosted: Wed Nov 21, 2007 11:55 am    Post subject: Reply with quote

بهترين لحظه براي چتر باز لحظه سقوط است
پس از سقوط نهراسيد


برنامه خيلي خوبي است ممنون
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> C/C++ Programming All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum