PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : برنامه های توپ برای c خوره ها



آبجی
13th April 2010, 03:21 AM
اولین برنامه محاسبه دترمینان چند جمله ای هاست

هلپ برنامه

Hello Developers,
I'm Pluskid And This Is My First Article Which I Write.
This Article Is About A Greatest Program For Computing Determinant Of A Polynomial Matrix.

Program Limitation

1.this program design and develop for polynomial arguman of degree 2 for each one.
2.you must enter all parameters (if there isn't ,enter zero)
3.maximum degree of matrix is 5
4.program has not any warden for your input integrity.

Example:

[2.3s^2-2 1.3s+1]
[2s^2+-.8s S^2+.6]

As Same As det( ) Function in Matlab.

for computing a determinant as above you must do to this way;
note.
P->>means Program output
U->>means User input

Run EXE;

P->>enter degree of matrix:
U->> 2 (enter)
P->>enter arguments of row[1]:
U->>2.3 0 -2 0 1.3 1 (enter)
P->>enter arguments of row[2]
U->>2 -.8 0 1 0 .6 (enter)
P->>output is shown now-----ENDP



About Author:

I'm Hossein Paimard From IRAN->Isfahan . i'm studying electronic in Shahrekord University.
i began my programming with c language and then continued with C++‎ , VB , Matlab , Html ,
JavaScript, PHP and VC++‎.Net is my ideal now.

you can contact me with Email Address -> pluskid2000@yahoo.com

اصل برنامه


کد:

#include<stdio.h>
#include<conio.h>
const volatile max=25;
int read(float[][max]);
void prog(float[][max],float[][max],float[],int);
void conv(float[],float[][max],float[],int);
void compute1(float[][max],float[][max],int);
void compute2(float[][max],float[][max],float[][max],int,int);
int main(){float num[6][max],g[6][max]={0},
p[15]={0};int dn,f,j,q,u,k,i=0;
dn=read(num);
compute1(num,g,dn+1);
prog(num,g,p,dn);
//input\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\
clrscr();
for(f=1;f<=dn;f++){
for(i=1;i<=dn;i++){
gotoxy(20*(i-1)+2,5+f);q=1+3*(i-1);
while(num[f][q]==0)q++;
if(3*i-q>0)printf("%3.1fs^%d",num[f][q],3*i-q);
for(k=q+1;k<3+(i-1)*3;k++){
if(num[f][k]==0);else{
if(num[f][k]>0)
printf("+%3.1fs^%d",num[f][k],i*3-k);
else printf("%3.1fs^%d",num[f][k],3*i-k);}}
if(num[f][3*i]<0)printf("%3.1f",num[f][3*i]);
else if(num[f][3*i]!=0)
printf("+%3.1f",num[f][3*i]);printf(" ");}}
//output\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\
i=0;while(p[i]==0)i++;
printf("\n\n\n\n determinan of matrix is:\n\n ");
if(dn*2+1-i)printf("%.4fs^%d",p[i],dn*2+1-i);
for(j=i+1;j<dn*2+1;j++){if(p[j]==0);
else{if(p[j]>0)
printf("+%.4fs^%d",p[j],dn*2+1-j);else
printf("%fs^%d",p[j],dn*2+1-j);}}
if(p[dn*2+1]<0)
printf("%.4f",p[dn*2+1]);
else if(p[dn*2+1]!=0)
printf("+%.4f",p[dn*2+1]);
getch();return 0;}
//************************************************** **************************
int read(float num[][25]){
int dn=0;clrscr();int register i,j;
printf("\nenter degree of matrix:");
scanf("%d",&dn);
clrscr();
for(i=1;i<=dn;i++){
printf("\n\n\nenter arguments of row[%d]:\n\n",i);
for(j=1;j<=dn*3;j++)
scanf("%f",&num[i][j]);}return dn;}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\
void prog(float num[][25],float g[][25],float p[],int dn){
int register u,i;float v[6][25]={0},h[50]={0};
for(u=1;u<=dn;u++){
compute1(g,v,dn);
if(dn-2)
prog(g,v,h,dn-1);
else{
h[1]=g[1][1];h[2]=g[1][2];h[3]=g[1][3];}
conv(h,num,p,u);
compute2(num,g,v,dn,u);
for(i=0;i<15;i++)
h[i]=0;}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\
void compute1(float g[][25],float v[][25],int dn){
int register i,j;
for(i=1;i<=(dn-2)*3;i++)
for(j=1;j<(dn-1);j++)
v[j][i]=g[j+1][i+3]; }
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\
void compute2(float num[][25],float g[][25],float v[][25],int dn,int u){
int register j;
for(j=1;j<dn;j++){
g[j][3*(u-1)+1]=num[j+1][3*(u-1)+1];g[j][3*(u-1)+2]=num[j+1][3*(u-1)+2];g[j][3*u]=num[j+1][3*u];}
for(j=1;j<dn-1;j++)
v[j][3*u-2]=g[j+1][3*u-2];v[j][3*u-1]=g[j+1][3*u-1];v[j][3*u]=g[j+1][3*u];}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void conv(float l[],float k[][25],float h[],int u){
int register i,j;
for(i=0;i<=15;i++)
for(j=1;j<=3;j++){
if(u%2)
h[j+i-1]+=l[i]*k[1][j+3*(u-1)];
else
h[j+i-1]-=l[i]*k[1][j+3*(u-1)];}}
//************************/\/\/\/\/\/\/\/\/\/\/\/\**************************//
// END OF PROGRAM //
// HOSSEIN PAIMARD //
// THURSDAY. APRIL 29-2005 //
// improve sauterday. january 28-2006 //
// PLUSKID2000 @ YAHOO.COM //
//*************************/\/\/\/\/\/\/\/\/\/\/\/**************************//

آبجی
13th April 2010, 03:23 AM
دوزبازی
اینم یه برنامه گرافیکی که البته دکمه هاش کار نمی ده ولی بدک نیست



#include<graphics.h>
#include <conio.h>
#include <stdio.h>
#include <dos.h>
#include <time.h>
#include <stdlib.h>
#define PLUSKID 1
#define ENEMY 0
#define ON 1
#define OFF 0
int T,F=4,S=3,H=12;
unsigned char A[9],B[9];
union REGS in,out;
union REGS InRegs;
union REGS OutRegs;
int prev_mouse_x=0;
int prev_mouse_y=0;
int callmouse()
{
in.x.ax=1;
int86(51,&in,&out);
return 1;
}
void mouseposi(int &xpos,int &ypos,int &click)
{
in.x.ax=3;
int86(51,&in,&out);
click=out.x.bx;
xpos=out.x.cx;
ypos=out.x.dx;
}
int mousehide()
{
in.x.ax=2;
int86(51,&in,&out);
return 1;
}
void setposi(int &xpos,int &ypos)
{
in.x.ax=4;
in.x.cx=xpos;
in.x.dx=ypos;
int86(51,&in,&out);
}
void resetmouse()
{in.x.ax=0;
int86(51,&in,&out);}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
in.x.ax=7;
in.x.cx=x1;
in.x.dx=x2;
int86(51,&in,&out);
in.x.ax=8;
in.x.cx=y1;
in.x.dx=y2;
int86(51,&in,&out);
}
void Intialize(void);
void First(void);
void PFir(void);
void Chk(void);
void Advertisement(int);
void Banner(int);
unsigned char PSec(void);
void Pluskid(void);
int Nextchk(void);
void CheckAlways(void);
int Ops(void);
int Lucky(void);
void Choose(void);
void CPU(void);
void main()
{
int i=10;
Intialize();
First();
PFir();
First();
Pluskid();
First();
Pluskid();
while(i--)
{
Choose();
CPU();
}
getch();
}

////////////////////////////////////////
//identify possiblity of pluskid conquer
int Lucky(void)
{
int i=1,u=0;
if(B[1]==ON && B[2]==ON && A[0]==OFF)
{
u+=i*1;i*=10;
}
if(B[4]==ON && B[8]==ON && A[0]==OFF)
{
u+=i*1;i*=10;
}
if(B[6]==ON && B[3]==ON && A[0]==OFF)
{
u+=i*1;i*=10;
}
if(B[0]==ON && B[2]==ON && A[1]==OFF)
{
u+=i*2;i*=10;
}
if(B[4]==ON && B[7]==ON && A[1]==OFF)
{
u+=i*2;i*=10;
}
if(B[0]==ON && B[1]==ON && A[2]==OFF)
{
u+=i*3;i*=10;
}
if(B[5]==ON && B[8]==ON && A[2]==OFF)
{
u+=i*3;i*=10;
}
if(B[4]==ON && B[6]==ON && A[2]==OFF)
{
u+=i*3;i*=10;
}
if(B[4]==ON && B[5]==ON && A[3]==OFF)
{
u+=i*4;i*=10;
}
if(B[0]==ON && B[6]==ON && A[3]==OFF)
{
u+=i*4;i*=10;
}
if(B[1]==ON && B[7]==ON && A[4]==OFF)
{
u+=i*5;i*=10;
}
if(B[3]==ON && B[5]==ON && A[4]==OFF)
{
u+=i*5;i*=10;
}
if(B[2]==ON && B[6]==ON && A[4]==OFF)
{
u+=i*5;i*=10;

}
if(B[0]==ON && B[8]==ON && A[4]==OFF)
{
u+=i*5;i*=10;

}
if(B[2]==ON && B[8]==ON && A[5]==OFF)
{
u+=i*6;i*=10;

}
if(B[4]==ON && B[3]==ON && A[5]==OFF)
{
u+=i*6;i*=10;

}
if(B[2]==ON && B[4]==ON && A[6]==OFF)
{
u+=i*7;i*=10;

}
if(B[7]==ON && B[8]==ON && A[6]==OFF)
{
u+=i*7;i*=10;

}
if(B[0]==ON && B[3]==ON && A[6]==OFF)
{
u+=i*7;i*=10;

}
if(B[1]==ON && B[4]==ON && A[7]==OFF)
{
u+=i*8;i*=10;

}
if(B[6]==ON && B[8]==ON && A[7]==OFF)
{
u+=i*8;i*=10;

}
if(B[0]==ON && B[4]==ON && A[8]==OFF)
{
u+=i*9;i*=10;

}
if(B[2]==ON && B[5]==ON && A[8]==OFF)
{
u+=i*9;i*=10;
}
if(B[6]==ON && B[7]==ON && A[8]==OFF)
{
u+=i*9;i*=10;
}
return u;
}
//identify if player is winner
int Ops(void)
{
int i=0;
if((A[1]==ON && A[2]==ON && A[0]==ON) || (A[0]==ON && A[3]==ON && A[6]==ON) ||
(A[0]==ON && A[4]==ON && A[8]==ON) || (A[1]==ON && A[4]==ON && A[7]==ON) ||
(A[2]==ON && A[5]==ON && A[8]==ON) || (A[2]==ON && A[4]==ON && A[6]==ON) ||
(A[4]==ON && A[3]==ON && A[5]==ON) || (A[6]==ON && A[7]==ON && A[8]==ON))
i=1;
return i;
}
//this is managment function

//Intialize\\\\\\\\\\\\\
void Intialize(void)
{
int driver,mode;
int x=160,y=120,r=30,m=3;
driver=DETECT;
initgraph(&driver,&mode,"");
rectangle(x-50,y-50,x+230,y+230);
circle(x,y,r);
setfillstyle(1,8);
floodfill(x+1,y+1,WHITE);
outtextxy(x+5,y+5,"1");
circle(x+m*r,y,r);
floodfill(x+1+m*r,y+1,WHITE);
outtextxy(x+5+m*r,y+5,"2");
circle(x+m*2*r,y,r);
floodfill(x+1+2*m*r,y+1,WHITE);
outtextxy(x+5+2*m*r,y+5,"3");
circle(x,y+m*r,r);
floodfill(x+1,y+1+m*r,WHITE);
outtextxy(x+5,y+5+m*r,"4");
circle(x+m*r,y+m*r,r);
floodfill(x+1+m*r,y+1+m*r,WHITE);
outtextxy(x+5+m*r,y+5+m*r,"5");
circle(x+2*m*r,y+m*r,r);
floodfill(x+1+2*m*r,y+1+m*r,WHITE);
outtextxy(x+5+2*m*r,y+5+m*r,"6");
circle(x,y+2*m*r,r);
floodfill(x+1,y+1+2*m*r,WHITE);
outtextxy(x+5,y+5+2*m*r,"7");
circle(x+m*r,y+2*m*r,r);
floodfill(x+1+m*r,y+1+2*m*r,WHITE);
outtextxy(x+5+m*r,y+5+2*m*r,"8");
circle(x+2*m*r,y+2*m*r,r);
floodfill(x+1+2*m*r,y+1+2*m*r,WHITE);
outtextxy(x+5+2*m*r,y+5+2*m*r,"9");
setfillstyle(6,9);
floodfill(x-48,y-48,WHITE);
setcolor(15);
rectangle(470,73,580,100);
rectangle(470,101,580,128);
rectangle(470,129,580,156);
rectangle(470,157,580,184);
rectangle(470,185,580,212);
rectangle(470,213,580,240);
rectangle(470,241,580,268);
setfillstyle(6,12);
floodfill(471,74,15);
floodfill(471,102,15);
floodfill(471,131,15);
floodfill(471,158,15);
floodfill(471,187,15);
floodfill(471,215,15);
floodfill(471,243,15);
setcolor(15);
settextstyle(3,0,1);
outtextxy(490,185," HELP ");
outtextxy(490,213," ABOUT ");
outtextxy(490,157," OPTION ");
outtextxy(490,129," LOAD ");
outtextxy(490,101," SAVE ");
outtextxy(486,73,"NEW GAME ");
outtextxy(490,241," QUIT ");
setcolor(12);
settextstyle(2,0,5);
outtextxy(140,350,"PLUSKID");
setcolor(9);
outtextxy(140,350," 2000 @ YAHOO . COM");
setcolor(2);
rectangle(400,280,630,460);
setfillstyle(6,9);
floodfill(402,283,2);
setcolor(14);
outtextxy(410,300,"Welcome To PLUSKID's World");
outtextxy(414,320,"I Begin This program in:");
outtextxy(410,340," August/30/2006 ");
outtextxy(402,360,"This is The First Version Of");
outtextxy(406,380,"The Game And My Second Game");
outtextxy(406,400,"I Hope You Will Enjoy Of It.");
outtextxy(410,440," Thank You, <Pluskid>");
struct tm *ptr;
time_t it;
it=time(NULL);
ptr=localtime(&it);
setcolor(14);
outtextxy(395,465,"Today:");
setcolor(11);
outtextxy(445,465,asctime(ptr));
setcolor(9);
settextstyle(4,1,99);
outtextxy(-40,20,"Pluskid");
settextstyle(3,0,2);
setcolor(4);
outtextxy(180,370,"Advertisement");
setcolor(1);
rectangle(110,400,390,476);
Banner(3);
}
//Advertisement\\\\\\\\\
void Advertisement(int)
{
setviewport(111,401,389,475,1);
clearviewport();
}
//Banner\\\\\\\\\\\\\\\\
void Banner(int i)
{
setviewport(100,3,635,68,1);
settextstyle(1,0,9);
switch(i%4)
{
case 0:
clearviewport();
setcolor(7);
outtextxy(0,-30,"DO");
outtextxy(420,-30,"OZ");
break;
case 1:
setcolor(8);
clearviewport();
outtextxy(50,-30,"DO");
outtextxy(370,-30,"OZ");
break;
case 2:
setcolor(4);
clearviewport();
outtextxy(100,-30,"DO");
outtextxy(320,-30,"OZ");
break;
case 3:
setcolor(15);
clearviewport();
outtextxy(150,-30,"DO");
outtextxy(260,-30,"OZ");
break;
}}
//Choose//////////////////////
void Choose(void)
{
int i,x,y,x1,y1,click,b,f=23,s=98;
setviewport(0,0,629,469,1);
restrictmouseptr(0,0,639,479);
callmouse();
LOOP:
click=0;
delay(200);
while(click==0)
mouseposi(x,y,click);
b=getpixel(x-1,y);
if(b==F)
{
mousehide();
for(b=0;b<9;b++)
if(x<190+(b%3)*90 && y<150+(b/3)*90)
{
f=b;
x=160+(b%3)*90;
y=120+(b/3)*90;
break;
}
setcolor(H);
circle(x,y,30);
circle(x,y,29);
}
else
goto LOOP;

callmouse();
LOOP1:
click=0;
delay(200);
while(click==0)
mouseposi(x1,y1,click);
b=getpixel(x1-1,y1);
if(b==F)
for(b=0;b<9;b++)
if(x1<190+(b%3)*90 && y1<150+(b/3)*90)
{
s=b;
break;
}
if(f==s)
{
setcolor(15);
circle(x,y,30);
setcolor(F);
circle(x,y,29);
goto LOOP;
//Choose();
}

if(b==8)
{
mousehide();
setfillstyle(1,F);
floodfill(x1,y1,WHITE);
setcolor(15);
circle(x,y,30);
setfillstyle(1,8);
floodfill(x,y,WHITE);
callmouse();
}
else
goto LOOP1;
callmouse();
}
//First\\\\\\\\\\\\\\\\\
void First(void)
{
int i,x,y,click,b;
setviewport(0,0,629,469,1);
restrictmouseptr(0,0,639,479);
callmouse();
LOOP:
click=0;
while(click==0)
mouseposi(x,y,click);
b=getpixel(x-1,y);
if(b==8)
{
mousehide();
setfillstyle(1,F);
floodfill(x,y,WHITE);
callmouse();
}
else
goto LOOP;
}
//PFir\\\\\\\\\\\\\\\\\\
void PFir(void)
{
int i;
randomize();
i=random(100);
mousehide();
setfillstyle(1,S);
if(getpixel(247,215)==F)
{
if(!(i%5))
floodfill(160,300,WHITE);
else if(!(i%6))
floodfill(340,120,WHITE);
else
floodfill(340,300,WHITE);
}
else
floodfill(250,210,WHITE);
callmouse();
}
//CPU\\\\\\\\\\\\\\\\\\
void CPU(void)
{
int i,j,s,l,test=0,test1=0,test2=0,test3=0,cont=3;
while(cont--)
{
for(i=0;i<9;i++)
{
Chk();
if(B[i]==ON)
{
B[i]=OFF;//1
j=Lucky();
if(j)
{
setfillstyle(1,8);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
i=j-1;
setfillstyle(1,S);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
return;
}
j=Nextchk();
if(j>10 || j==i+1)
continue;
if(j)
{
setfillstyle(1,8);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
i=j-1;
setfillstyle(1,S);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
return;
}
for(s=0;s<9 && s!=i;s++)
if(B[s]==OFF && A[s]==OFF)
{//111
B[s]=ON;//2
j=Lucky();
if(j>10)
{
setfillstyle(1,8);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
setfillstyle(1,S);
floodfill(160+(s%3)*90,120+(s/3)*90,WHITE);
return;
}
else if(j)
{
A[j-1]=ON;//3
for(l=0;l<9 && l!=j-1;l++)
if(A[l]==ON)
{
A[l]=OFF;
if(Lucky())
{
A[l]=ON;
continue;
}
if(Nextchk())
test2=ON;
if(Nextchk()>10)
{
test3=ON;
break;
}
}
if(!test3 && test)
{
setfillstyle(1,8);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
setfillstyle(1,S);
floodfill(160+(s%3)*90,120+(s/3)*90,WHITE);
return;
}
}

}//111
}//if
}//for
if(cont==2)
test=1;
if(cont==1)
test1=1;
}//while
}
//Pluskid\\\\\\\\\\\\\\\
void Pluskid(void)
{
int i,j,test=0,test1=0,cont=3;
setfillstyle(1,S);
if(PSec())
return;
while(cont--)
{
for(i=0;i<9;i++)
{
Chk();
//printf("oh %d %d %d\n%d%d%d%d%d%d%d%d%d\n",i,test,test1,B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7],B[8]);
if(B[i]==OFF && A[i]==OFF)
{
B[i]=ON;//1
j=Lucky();
if(!j)
continue;

if(j>10)
{
//printf("oh %d %d\n%d%d%d%d%d%d%d%d%d",test,test1,B[0],B[1],B[2],B[3],B[4],B[5],B[6],B[7],B[8]);
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
return;
}
A[j-1]=ON;//2
if(!Nextchk() && test )
{
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
return;
}
if(Nextchk() && !test)
continue;
if(Nextchk()<10 && test && test1)
{
floodfill(160+(i%3)*90,120+(i/3)*90,WHITE);
return;
}

}
}
if(cont==2)
test=1;
if(cont==1)
test1=1;
}
}
//PSec\\\\\\\\\\\\\\\\\\
unsigned char PSec(void)
{
int i;
Chk();
i=Lucky();
i%=10;
if(i)
{
if(i==1)
floodfill(160,120,WHITE);
if(i==2)
floodfill(250,120,WHITE);
if(i==3)
floodfill(340,120,WHITE);
if(i==4)
floodfill(160,210,WHITE);
if(i==5)
floodfill(250,210,WHITE);
if(i==6)
floodfill(340,210,WHITE);
if(i==7)
floodfill(160,300,WHITE);
if(i==8)
floodfill(250,300,WHITE);
if(i==9)
floodfill(340,300,WHITE);
return 1;
}
i=Nextchk();
printf("%d",i);
i%=10;
if(i)
{
if(i==1)
floodfill(160,120,WHITE);
if(i==2)
floodfill(250,120,WHITE);
if(i==3)
floodfill(340,120,WHITE);
if(i==4)
floodfill(160,210,WHITE);
if(i==5)
floodfill(250,210,WHITE);
if(i==6)
floodfill(340,210,WHITE);
if(i==7)
floodfill(160,300,WHITE);
if(i==8)
floodfill(250,300,WHITE);
if(i==9)
floodfill(340,300,WHITE);
return 1;
}
return 0;
}


//Chk\\\\\\\\\\\\\\\\\\\
void Chk(void)
{
mousehide();
if(getpixel(150,125)==F)
A[0]=1;
else
A[0]=0;
if(getpixel(240,125)==F)
A[1]=1;
else
A[1]=0;
if(getpixel(330,125)==F)
A[2]=1;
else
A[2]=0;
if(getpixel(150,215)==F)
A[3]=1;
else
A[3]=0;
if(getpixel(250,215)==F)
A[4]=1;
else
A[4]=0;
if(getpixel(340,210)==F)
A[5]=1;
else
A[5]=0;
if(getpixel(150,305)==F)
A[6]=1;
else
A[6]=0;
if(getpixel(250,305)==F)
A[7]=1;
else
A[7]=0;
if(getpixel(340,305)==F)
A[8]=1;
else
A[8]=0;
if(getpixel(160,125)==S)
B[0]=1;
else
B[0]=0;
if(getpixel(240,125)==S)
B[1]=1;
else
B[1]=0;
if(getpixel(330,125)==S)
B[2]=1;
else
B[2]=0;
if(getpixel(150,215)==S)
B[3]=1;
else
B[3]=0;
if(getpixel(250,210)==S)
B[4]=1;
else
B[4]=0;
if(getpixel(330,215)==S)
B[5]=1;
else
B[5]=0;
if(getpixel(150,305)==S)
B[6]=1;
else
B[6]=0;
if(getpixel(240,305)==S)
B[7]=1;
else
B[7]=0;
if(getpixel(330,305)==S)
B[8]=1;
else
B[8]=0;
callmouse();
}
//Nextchk\\\\\\\\\\\\\\\\\\\\
int Nextchk(void)
{
int i=1,u=0;
if(A[6]==ON && A[3]==ON && B[0]==OFF)
{
u+=i*1;i*=10;
}
if(A[1]==ON && A[2]==ON && B[0]==OFF)
{
u+=i*1;i*=10;
}
if(A[4]==ON && A[8]==ON && B[0]==OFF)
{
u+=i*1;i*=10;
}
if(A[0]==ON && A[2]==ON && B[1]==OFF)
{
u+=i*2;i*=10;
}
if(A[4]==ON && A[7]==ON && B[1]==OFF)
{
u+=i*2;i*=10;
}
if(A[0]==ON && A[1]==ON && B[2]==OFF)
{
u+=i*3;i*=10;
}
if(A[5]==ON && A[8]==ON && B[2]==OFF)
{
u+=i*3;i*=10;
}
if(A[4]==ON && A[6]==ON && B[2]==OFF)
{
u+=i*3;i*=10;
}
if(A[0]==ON && A[6]==ON && B[3]==OFF)
{
u+=i*4;i*=10;
}
if(A[4]==ON && A[5]==ON && B[3]==OFF)
{
u+=i*4;i*=10;
}
if(A[1]==ON && A[7]==ON && B[4]==OFF)
{
u+=i*5;i*=10;
}
if(A[3]==ON && A[5]==ON && B[4]==OFF)
{
u+=i*5;i*=10;
}
if(A[2]==ON && A[6]==ON && B[4]==OFF)
{
u+=i*5;i*=10;
}
if(A[0]==ON && A[8]==ON && B[4]==OFF)
{
u+=i*5;i*=10;
}
if(A[3]==ON && A[4]==ON && B[5]==OFF)
{
u+=i*6;i*=10;
}
if(A[2]==ON && A[8]==ON && B[5]==OFF)
{
u+=i*6;i*=10;
}
if(A[0]==ON && A[3]==ON && B[6]==OFF)
{
u+=i*7;i*=10;
}
if(A[2]==ON && A[4]==ON && B[6]==OFF)
{
u+=i*7;i*=10;
}
if(A[7]==ON && A[8]==ON && B[6]==OFF)
{
u+=i*7;i*=10;
}
if(A[1]==ON && A[4]==ON && B[7]==OFF)
{
u+=i*8;i*=10;
}
if(A[6]==ON && A[8]==ON && B[7]==OFF)
{
u+=i*8;i*=10;
}
if(A[0]==ON && A[4]==ON && B[8]==OFF)
{
u+=i*9;i*=10;
}
if(A[2]==ON && A[5]==ON && B[8]==OFF)
{
u+=i*9;i*=10;
}
if(A[6]==ON && A[7]==ON && B[8]==OFF)
{
u+=i*9;i*=10;
}
return u;

آبجی
13th April 2010, 03:24 AM
محاسبه معکوس ماتریس


#include<stdio.h>
#include<conio.h>
#include<alloc.h>
const volatile max=15;
int read(float[][max],float[][max]);
void compute1(float[][max],float[][max],float[][max],int,int,int,float);
float compute2(float[][max],int);
void display(float[][max],float[][max],int,float);
int main(){
float num[max][max],g[max][max],v[max][max],a[max][max];int dn,u;float det;
int register i,j;
dn=read(num,a);
det=compute2(num,dn);
for(i=0;i<dn;i++)
for(j=0;j<dn;j++){
compute1(a,g,v,dn,i,j,det);}
display(a,v,dn,det);
getch();
return 0;}
//************************************************** **************************
int read(float num[][max],float a[][max]){
int dn;clrscr();int register i,j;
printf("\nenter degree of matrix:");
scanf("%d",&dn);
clrscr();
for(i=0;i<dn;i++){
printf("\n\n\nenter arguments of row[%d]:\n\n",i);
for(j=0;j<dn;j++){
scanf("%f",*(num+i)+j);
*(*(a+i)+j)=*(*(num+i)+j);}}return dn;}
//************************************************** **************************
void display(float c[][max],float inv[][max],int dn,float det){
int register i,j;clrscr();
printf("\n\n\n\n\n\t\t\t --ORIGINAL MATRIX--\n");
for(i=0;i<dn;i++){
printf("\n\t\t");
for(j=0;j<dn;j++)
printf("%10.3f",c[i][j]);}
printf("\n\n\n\t\t\t --INVERSE MATRIX--\n");
for(i=0;i<dn;i++){
printf("\n\t\t");
for(j=0;j<dn;j++)
printf("%10.6f ",inv[i][j]);}
printf("\n\n\n\t\tعؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؟");
printf("\n\t\t³ determinan of matrix= %19.7f ³ ",det);
printf("\n\t\tہؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤظ");
}
//************************************************** **************************
void compute1(float g[][max],float v[][max],float inv1[][max],int dn,int r,int c,float e){
int col=0,row=0,add=r+c,y;float y1=1;
if(add%2)
y1=-1;
int register i,j;
for(i=0;i<dn-1;i++){
if(i==r)
row=1;
col=0;
for(j=0;j<dn-1;j++){
if(j==c)
col=1;
v[i][j]=g[i+row][j+col];}}
inv1[c][r]=y1*compute2(v,dn-1)/e;}
//************************************************** **************************
float compute2(float c[][max],int s){
float *h=(float*)malloc(sizeof(float)),h1=1;int y=s-1,k=s;
int register i,j;
while(y>0){
for(i=1;i<k;i++){
if(c[y][y]!=0)
h[i-1]=c[y-i][y]/c[y][y];
else{
for(j=0;j<s;j++)
c[y][j]+=c[y-i][j];
h[i-1]=c[y-i][y]/c[y][y];}}
y--;k--;
for(i=0;i<k;i++)
for(j=s-1;j>=0;j--)
c[y-i][j]=c[y-i][j]-h[i]*c[y+1][j];}
for(i=0;i<s;i++)
h1*=c[i][i];return h1;}
//************************\/\/\/\/\/\/\/\/\/\/\/\/**************************//
// END OF PROGRAM //
// HOSSEIN PAIMARD //
// wednsday. january 25-2006 //
// 11:57 A.M
// PLUSKID2000 @ YAHOO.COM //
//************************/\/\/\/\/\/\/\/\/\/\/\/***************************//

آبجی
13th April 2010, 03:25 AM
بازی بیدل
اینم یه بازی گرافیکیه عالی با سی


#include<graphics.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
union REGS in,out;
union REGS InRegs;
union REGS OutRegs;
int prev_mouse_x=0;
int prev_mouse_y=0;
void mouse( )
{
InRegs.x.ax=0x0001;
int86(0x33,&InRegs,&OutRegs);
}

int callmouse()
{
in.x.ax=1;
int86(51,&in,&out);
return 1;
}
void mouseposi(int &xpos,int &ypos,int &click)
{
in.x.ax=3;
int86(51,&in,&out);
click=out.x.bx;
xpos=out.x.cx;
ypos=out.x.dx;
}
int mousehide()
{
in.x.ax=2;
int86(51,&in,&out);
return 1;
}
void setposi(int &xpos,int &ypos)
{
in.x.ax=4;
in.x.cx=xpos;
in.x.dx=ypos;
int86(51,&in,&out);
}
void resetmouse()
{in.x.ax=0;
int86(51,&in,&out);}
void restrictmouseptr(int x1,int y1,int x2,int y2)
{
in.x.ax=7;
in.x.cx=x1;
in.x.dx=x2;
int86(51,&in,&out);
in.x.ax=8;
in.x.cx=y1;
in.x.dx=y2;
int86(51,&in,&out);
}
#define con 20
#define add 13
void input(int[],int[]);
void motion(int[],int);
void dis(int,int,int,int,int);
void club(int,int);
void hearts(int,int);
void spade(int,int);
void diamond(int,int);
void begin(int[],int[]);
void intialize(int[]);
void call(int[],int[],int[]);
int pluskid(int[],int[],int);
int score(int,int[],int[],int,int[],int);
int now(int,int[],int[]);
int move(int,int,int[],int[],int);
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\
void main(){
int d=DETECT,m=0;
initgraph(&d,&m,"");
restrictmouseptr(3,1,637,447);
int adv[4]={0};int sc[4]={0};
while(1){
input(adv,sc);}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void intialize(int array[52]){
int i,j,s,k,player,face;
randomize();
for(j=0;j<4;j++)
for(i=1+j*con;i<14+j*con;i++){
player=random(52);
while(array[player]!=0)
player=random(52);
array[player]=i;}
for(k=0;k<4;k++)
for(i=k*add;i<13+k*add;i++)
for(j=12+k*add;j>i;j--)
if(array[i]>array[j]){
face=array[i];array[i]=array[j];array[j]=face;}
for(k=1;k<4;k++)
for(i=k*add;i<13+k*add;i++)
for(j=12+k*add;j>i;j--)
if(array[i]<array[j] && ((array[j]<14 && array[i]<14) || (20<array[j] && 20<array[i] && array[i]<34 && array[j]<34) || (40<array[j] && 40<array[i] && array[i]<54 && array[j]<54) || (60<array[j] && 60<array[i] && array[i]<74 && array[j]<74)) ){
face=array[i];array[i]=array[j];array[j]=face;}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\
int pluskid(int plus[52],int a[4],int cv){
char h;int f,q,e,i,j,s,k,m,g,x,y,cl=0,b=0,n,p=0,l=0;
setposi(550,430);
callmouse();
for(j=0;j<add;j++)
if(plus[j]>cv && plus[j]<cv+14){
l=13;break;}
while(1){
while(cl==0 || cl==2)
mouseposi(x,y,cl);
y=y>475 ? y/10 : y;
sound(3000);
delay(9);
nosound();
for(n=0;n<7;n++){
if(x>10+n*90 && x<93+n*90)
if(y>210 && y<340){
b=n+1;break;}
else if(y>345 && y<475){
b=n+8;break;}}
if(b==0 || b==14){cl=0;b=0;continue;}
for(n=0;n<13;n++){
if(plus[n]!=0)
p++;
if(p==b){
if(l==0){
a[0]=plus[n];
plus[n]=0;
m=0;break;}
else
if(plus[n]>cv && plus[n]<cv+14){
a[0]=plus[n];
plus[n]=0;
m=0;break;}p=15;break;}}
if(p!=b){b=0;cl=0;p=0;continue;}
if(a[0]>20)
m=20;
if(a[0]>40)
m=40;
if(a[0]>60)
m=60;
return m;}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\
int move(int i,int m,int plus[52],int a[4],int w){
int j,s,f=0,q,k=-1;//need to improve
for(j=i*add;j<add*(i+1);j++){
if(plus[j]==71 && plus[j]>m && plus[j]<a[w]){
a[i]=plus[j];plus[j]=0;return w;}
else if(plus[j]==71){
k=j;break;}else;}
for(j=i*add;j<add*(i+1);j++){
if(plus[j]>m && plus[j]<a[w]){
a[i]=plus[j];plus[j]=0;s=j;f=1;break;}
else if(a[w]<plus[j] && plus[j]<m+14){
a[i]=plus[j];s=j;f=1;w=i;//need to improvment for i=2 stage
}else;}
if(f==1)
plus[s]=0;
else{//need to improvment
if(k!=-1){
a[i]=plus[k];plus[k]=0;return w;}
q=0;m=i*add;
while(plus[m+q]==0)
q++;
a[i]=plus[m+q];plus[m+q]=0;}
return w;}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\
int now(int w,int us[52],int a[4]){
int i;int val=14,v,c,m;//begin of movement with PC
for(i=w*add;i<(w+1)*add;i++){
v=us[i];
if(v>0 && (v%20)<(val%20)){
val=v;c=i;m=(v/20)*20;}else;}
a[w]=val;us[c]=0;
return m;}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
int score(int a[4],int m,int kid[4],int w,int sc[4],int ctl){
int i,min=100;int j=w,h=a[w];
if(ctl==0){
for(i=0;i<4;i++)
if(a[i]>m && a[i]<m+14 && h<a[i]){
h=a[i];j=i;}
for(i=0;i<4;i++){
if(a[i]>0 && a[i]<14)
sc[j]++;//j is lost this stage
else if(a[i]==71)
sc[j]+=13;}
return j;}
else{
for(i=0;i<4;i++)
if(sc[i]==26){
for(j=0;j<4;j++)
if(j!=i)
kid[j]+=26;return j;}
for(i=0;i<4;i++)
kid[i]+=sc[i];
for(i=0;i<4;i++){
if(kid[i]<min){
min=kid[i];j=i;}
if(kid[i]>99)
w=100;}
if(w==100){
kid[0]=kid[1]=kid[2]=kid[3]=0;
cleardevice();
setcolor(4);
settextstyle(3,0,19);
if(j==0)
outtextxy(30,200,"YOU WIN");
else
outtextxy(30,200,"YOU LOST");
delay(3000);cleardevice();}
return i;}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void input(int adv[4],int sc[4]){
int x,y,cl=0,i=-2,j,color=14,a1=3;int u[52]={0},a[4]={0};
setposi(460,30);
mouse();
sc[3]=0;sc[1]=0;sc[2]=0;sc[0]=0;
call(u,adv,sc);
setcolor(4);
settextstyle(1,0,9);
outtextxy(110,25,"HEARTS");
settextstyle(3,0,1);
outtextxy(200,250," Developed And Designed:");
settextstyle(4,0,19);
outtextxy(120,250,"PlusKid");
setcolor(a1);
settextstyle(0,0,1);
setfillstyle(1,4);
rectangle(500,30,580,50);
settextstyle(0,0,1);
floodfill(503,33,a1);
outtextxy(509,35," NEW");
rectangle(500,60,580,80);
floodfill(503,65,a1);
outtextxy(508,67," HELP");
rectangle(500,90,580,110);
floodfill(503,93,a1);
outtextxy(509,95,"CONTINUE");
rectangle(500,120,580,140);
floodfill(503,125,a1);
outtextxy(508,125," ABOUT");
rectangle(500,150,580,170);
floodfill(503,152,a1);
outtextxy(508,155," QUIT");
settextstyle(0,0,1);
while(cl==0 || cl==2){
mouseposi(x,y,cl);
while(y>33 && y<49 && (cl==0 || cl==2) && x>510 && x<570){
mouseposi(x,y,cl);
i=0;
setcolor(color);
rectangle(500,30,580,50);}
setcolor(a1);
rectangle(500,30,580,50);
while(y>61 && y<80 && (cl==0 || cl==2) && x>510 && x<570){
mouseposi(x,y,cl);
setcolor(color);
rectangle(500,60,580,80);
i=1;}
setcolor(a1);
rectangle(500,60,580,80);
while(y>90 && y<110 && (cl==0 || cl==2) && x>510 && x<570){
mouseposi(x,y,cl);
setcolor(color);
rectangle(500,90,580,110);
i=2;}
setcolor(a1);
rectangle(500,90,580,110);
while(y>120 && y<140 && (cl==0 || cl==2) && x>510 && x<570){
setcolor(color);
mouseposi(x,y,cl);
i=3;
rectangle(500,120,580,140);}
setcolor(a1);
rectangle(500,120,580,140);
while(y>151 && y<170 && (cl==0 || cl==2) && x>510 && x<570){
setcolor(color);
mouseposi(x,y,cl);
i=4;
rectangle(500,150,580,170);}
setcolor(a1);
rectangle(500,150,580,170);}
switch(i){
case 0:
begin(a,sc);
break;
case 1:
mousehide();
setviewport(120,110,520,330,1);
clearviewport();
floodfill(1,1,2);
window(10,10,240,250);
bar3d(0,0,390,240,10,0);
setcolor(11);
highvideo();
outtextxy(28,5," IN THE NAME OF GOD ");
outtextxy(20,25," Introduce Of This Game ");
outtextxy(20,45," WithOut Heart And Spade Queen");
outtextxy(1,65," You Are Pluskid.");
outtextxy(20,85," Spade Queen Is Equal -13");
outtextxy(30,105," Every Heart Which You Get Is Equal -1");
outtextxy(20,125," The Winner's Name Is Red");
outtextxy(1,145," Game Is Continued Till Somebody Get -100 Score");
outtextxy(1,165,"Whatever Your Score Is Higher You're Loser Sooner");
outtextxy(30,200," Sunday,May 07,2006");
delay(15000);
setfillstyle(11,8);
floodfill(10,10,4);
setviewport(0,0,639,479,1);
cleardevice();
call(u,adv,sc);
i=-1;
input(adv,sc);
break;
case 2:
if(adv[0]==0 && adv[1]==0 && adv[2]==0 && adv[3]==0){
mousehide();
setviewport(140,110,400,190,1);
clearviewport();
floodfill(1,1,2);
window(10,10,240,250);
bar3d(0,0,250,80,10,0);
setcolor(11);
highvideo();
outtextxy(28,40,"YOU DON'T BEGIN ANY GAME ");
delay(1500);
setfillstyle(11,8);
floodfill(10,10,4);
setviewport(0,0,639,479,1);
cleardevice();
break;}
begin(adv,sc);
break;
case 4:
exit(1);
break;
case 3:
mousehide();
setviewport(200,110,460,300,1);
clearviewport();
floodfill(1,1,2);
window(10,10,200,250);
bar3d(0,0,250,190,10,0);
setcolor(14);
highvideo();
outtextxy(8,5," IN THE NAME OF GOD ");
outtextxy(1,45," Developed And Published By: ");
outtextxy(1,70," Hossein Paimard");
outtextxy(1,100," Pluskid2000@yahoo.com");
outtextxy(1,130," Sunday,May 07,2006");
delay(6000);
setfillstyle(11,8);
floodfill(10,10,4);
setviewport(0,0,639,479,1);
cleardevice();
call(u,adv,sc);
i=-1;
input(adv,sc);
break;
}}

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void begin(int adv[4],int sc[4]){
int a[4]={0},j,i,w,m,s=13,cl=0,x,y,ss;
//call(plus,adv);
int plus[52]={0};
intialize(plus);
//input(adv);
w=random(4);
j=w;
while(s--){
mousehide();
call(plus,adv,sc);
if(w==0)
m=pluskid(plus,a,-100);
else
m=now(w,plus,a);
motion(a,w);
for(i=w+1;i<w+4;i++){
if((i%4)==0)
pluskid(plus,a,m);
else
j=move(i%4,m,plus,a,j);
motion(a,i%4);}
setposi(540,345);
w=score(a,m,adv,w,sc,0);
j=w;
mousehide();
delay(1500);
clearviewport();}
score(a,m,adv,w,sc,1);
input(adv,sc);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void motion(int a[4],int i){
int j,f;
j=a[i]/con;
f=a[i]%con;
dis(f,i,j,1+i,-180);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void club(int i,int j){
setcolor(0);
circle(i+8,j+2,4);
circle(i+4,j+9,4);
circle(i+13,j+9,4);
rectangle(i+5,j+13,i+11,j+18);
setfillstyle(0,10);
putpixel(i+9,j+6,5);
putpixel(i+8,j+12,0);
putpixel(i+9,j+12,0);
putpixel(i+8,j+11,0);
putpixel(i+9,j+11,0);
floodfill(i+9,j+16,0);
floodfill(i+8,j+2,0);
floodfill(i+5,j+9,0);
floodfill(i+11,j+9,0); }
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void call(int array[52],int adv[4],int sc[4]){
int s,j,k=0,i,m=0,x,y,cl,min=10,min1=10,yy=-1,nn=-1;
char p0[3]={0},p1[3]={0},p2[3]={0},p3[3]={0},p10[3]={0},p11[3]={0},p12[3]={0},p13[3]={0};
//resetmouse();
for(i=0;i<13;i++){
s=array[i];
if(s==0)continue;
if(s<14+k*con){
switch(k){
case 0:k=0;
dis(s,m,0,m,0);m++;
break;//call hearts
case 1:k=0;
dis(s-con,m,1,m,0);m++;break;//call club
case 2:k=0;
dis(s-2*con,m,2,m,0);m++;
break;
case 3:k=0;
dis(s-3*con,m,3,m,0);m++;
break;}}
else{
k++;i--;}}
setcolor(4);
settextstyle(1,0,9);
outtextxy(110,25,"HEARTS");
settextstyle(0,0,1);
setcolor(4);
setfillstyle(1,4);
ellipse(54,13,0,360,46,12);
floodfill(55,14,4);
setcolor(15);
outtextxy(11,10,"TOTAL SCORE");
setcolor(4);
ellipse(54,175,0,360,46,12);
floodfill(55,176,4);
setcolor(15);
outtextxy(10,172,"STAGE SCORE");
setcolor(2);
min=min1=100;
for(int o=0;o<4;o++)
if(adv[o]<min){
min=adv[o];yy=o;}
for(o=0;o<4;o++)
if(sc[o]<min1){
min1=sc[o];nn=o;}
itoa(adv[0],p0,10);itoa(adv[1],p1,10);
itoa(adv[2],p2,10);itoa(adv[3],p3,10);
itoa(sc[0],p10,10);itoa(sc[1],p11,10);
itoa(sc[2],p12,10);itoa(sc[3],p13,10);
if(yy==0)
setcolor(4);
else
setcolor(3);
outtextxy(25,37,"Pluskid");outtextxy(45,52,p0);
if(nn==0)
setcolor(4);
else
setcolor(3);
outtextxy(113,168,"Pluskid");outtextxy(130,185,p10);
if(yy==1)
setcolor(4);
else
setcolor(3);
outtextxy(25,67,"Hossein");outtextxy(45,82,p1);
if(nn==1)
setcolor(4);
else
setcolor(3);
outtextxy(203,168,"Hossein");outtextxy(223,185,p11);
if(yy==2)
setcolor(4);
else
setcolor(3);
outtextxy(25,97,"Michael");outtextxy(45,112,p2);
if(nn==2)
setcolor(4);
else
setcolor(3);
outtextxy(290,168,"Michael");outtextxy(315,185,p12);
if(yy==3)
setcolor(4);
else
setcolor(3);
outtextxy(25,127,"Carlson");outtextxy(45,142,p3);
if(nn==3)
setcolor(4);
else
setcolor(3);
outtextxy(380,168,"Carlson");outtextxy(405,185,p13);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void dis(int i,int m,int g,int z,int s){
int x,y,spot[30]={0},r;char j[20]={0};
setfillstyle(11,8);
setcolor(3);
floodfill(10,10,4);
i++;
rectangle(0,200,639,479);
setposi(590,370);
callmouse();
if(i==14){
strcpy(j," ACE");
i=1;}
else if(i==13){
strcpy(j," KING");
i=1;}
else if(i==12){
strcpy(j,"QUEEN");
i=1;}
else if(i==11){
strcpy(j," JACK");
i=1;}
else
itoa(i,j,10);
if(m>6){
z=m-7;
s=135;}
y=93+90*z;
x=3+z*90;
rectangle(x+7,210+s,y,340+s);
setfillstyle(1,15);
floodfill(x+8,211+s,3);
outtextxy(x+11,214+s,j);
spot[0]=x+28;spot[1]=215+s;
spot[2]=x+55;spot[3]=spot[1];
spot[4]=spot[0];spot[5]=239+s;
spot[6]=spot[2];spot[7]=spot[5];
spot[8]=spot[0];spot[9]=263+s;
spot[10]=spot[2];spot[11]=spot[9];
spot[12]=spot[0];spot[13]=289+s;
spot[14]=spot[2];spot[15]=spot[13];
spot[16]=spot[0];spot[17]=313+s;
spot[18]=spot[2];spot[19]=spot[17];
switch(g){
case 0:
if(i==1){
hearts(x+43,spot[11]);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(x+12,spot[11]-28,j);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);}
else
for(r=0;r<i;r++)
hearts(spot[r*2],spot[r*2+1]);
break;
case 1:
if(i==1){
club(x+43,spot[11]);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(x+12,spot[11]-28,j);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);}
else
for(r=0;r<i;r++)
club(spot[r*2],spot[r*2+1]+2);
break;
case 2:
if(i==1){
diamond(x+43,spot[11]);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(x+12,spot[11]-28,j);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);}
else
for(r=0;r<i;r++)
diamond(spot[r*2],spot[r*2+1]);
break;
case 3:
if(i==1){
spade(x+43,spot[11]);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(x+12,spot[11]-28,j);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);}
else
for(r=0;r<i;r++)
spade(spot[r*2],spot[r*2+1]);
break;}}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void diamond(int i,int j){
int p[10]={0};
char pattern[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
setcolor(4);
p[0]=i;p[1]=j+12;p[2]=i+7;p[3]=j+1;p[4]=i+14;
p[5]=j+12;p[6]=i+7;p[7]=j+24;p[8]=i;p[9]=j+12;
drawpoly(5,p);
setfillpattern(pattern,4);
fillpoly(5,p);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void hearts(int i,int j){
int p[10]={0};
char pattern[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
setcolor(4);
p[0]=i;p[1]=j+12;p[2]=i+7;p[3]=j+23;p[4]=i+14;p[5]=j+12;p[6]=i;p[7]=j+12;
drawpoly(4,p);
setfillpattern(pattern,4);
fillpoly(4,p);
circle(i+3,j+9,4);
circle(i+11,j+9,4);
putpixel(i+8,j+11,0);
putpixel(i+9,j+11,0);
floodfill(i+3,j+9,4);
floodfill(i+11,j+9,4);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void spade(int i,int j){
int p[10]={0};
char pattern[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
setcolor(0);
p[0]=i;p[1]=j+14;p[2]=i+7;p[3]=j+2;p[4]=i+14;p[5]=j+14;p[6]=i;p[7]=j+14;
drawpoly(4,p);
setfillpattern(pattern,0);
fillpoly(4,p);
circle(i+4,j+15,4);
circle(i+10,j+15,4);
rectangle(i+5,j+16,i+9,j+24);
putpixel(i+7,j+15,0);
putpixel(i+6,j+17,0);
putpixel(i+8,j+17,0);
floodfill(i+8,j+21,0);
floodfill(i+4,j+15,0);
floodfill(i+10,j+15,0);}
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

آبجی
13th April 2010, 03:26 AM
نمایش مقسوم علیه های یک عدد
در این برنامه شما می تو انید با وارد کردن عدد خود در محدوده عدد صحیح
تمام مقسوم علیه های آن عدد را ببینید



#include<stdio.h>
#include<conio.h>

main()
{
int i,x,u,k,j,jj[10],con,m,bool,cons,mm,a[30][2],fil=0,bool1=0;
char *plus="PLUSKID2000@YAHOO.COM PLUSKID";
clrscr();
printf("enter your number:");
scanf("%d",&k);
clrscr();
printf(" PLUSKID is calculating denominators of < %d >\n\n\n",k);
m=k;
bool=0;
mm=0;
cons=1;
j=1;
x=2;
con=-1;
while(x<=k/2)
{
for(i=x;i<=k;i++)
if(k%i==0)
{
bool=10;
con++;
jj[con]=i;
k/=i;
j+=i;
i=cons;
}
u=k;
k=m;
if(bool==10 && mm++<k/2)
{
if(u==1)
{
for(int vb=0;vb<fil+1;vb++)
if(j==a[vb][0] && a[vb][1]==con)bool1++;
if(bool1==0)
{
a[fil][0]=j;
a[fil++][1]=con;
printf("\n %c ق [%02d]->",plus[fil-1],fil);
for(int gh=0;gh<con;gh++)
printf(" %d *",jj[gh]);
printf(" %d\n ق",jj[con]);
if(fil%10==0)
getch();
//printf("\t=sum is %10d",j);
}
}
bool1=0;
cons++;
con=-1;
j=0;
bool=0;
}
if(++mm>k/2)
{
x++;
mm=1;
cons=1;
}
k=m;
con=-1;
j=1;
}
printf("\n %c ق\n ق\n %c قــــــــــــــــــــــــ ــــــــــــــــ\n\n %c",plus[fil],plus[fil+1],plus[fil+2] );
for(i=fil+3;i<21;i++)
printf(" %c",plus[i]);
printf("\n\n\n\n\n\tThere Are < %d > Denominators For"
" [ %d ]\n\n\t\tPLUSKID:->Thank You->BYE%c",fil,m,7);
getch();
}
///////////////////////\/\/\/\/from taurus/\/\/\/\/\\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////// Design And Develop By: \\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////// Hossain Pymard \\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////// Pluskid2000 @ Yahoo.Com \\\\\\\\\\\\\\\\\\\\\\\\\\\\
//////////////////////\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\

آبجی
13th April 2010, 03:26 AM
برنامه محاسبه ماتریس بالاوپایین مثلثی و دترمینان با دو تقریب
این برنامه ماتریس مربعی رو می گیره و ماتریس بالا و پایین مثلثی شو با دترمینانش چا پ می کنه



#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<string.h>
const volatile int max=10;
void output(float[][max],float[][max],float[][max],int);
void calculateU(float[][max],int);
void calculateL(float[][max],int);
void finish(void);
int input(float[][max],float[][max],float[][max]);
int main(){
clrscr();int s;char u;
float c[max][max],c1[max][max],c2[max][max];
do{
s=input(c,c1,c2);
calculateU(c1,s);
calculateL(c2,s);
output(c,c1,c2,s);
u=getch();
}while(u!='n' && u!='N');finish();getch();return 0;}
//input//////////////////////////////////////////////////////////////////////////
int input(float a[][max],float a1[][max],float a2[][max]){
clrscr();int s;int register i,j;
printf("\n\ncomment:\n\n << this program calculate triU & triL of a special squre matrix >>\n\t << with constant determinan of original matrix >>\n\t << also provide determinan with 2'ways >>\n\n\nbegin:\n enter degree of matrix:");
scanf("%d",&s);clrscr();
for(i=0;i<s;i++){
printf("\nplease inter arguments of row %d:\n",i+1);
for(j=0;j<s;j++){
scanf("%f",*(a+i)+j);
*(*(a2+i)+j)=*(*(a1+i)+j)=*(*(a+i)+j);}}return s;}
//output///////////////////////////////////////////////////////////////////////
void output(float o[][max],float o1[][max],float o2[][max],int s){
clrscr();int register i,j;double h1=1,h2=1;
for(i=0;i<s;i++){
h1*=o1[i][i];h2*=o2[i][i];}
printf("\n\n\n\t\t\t ORIGINAL MATRIX\n");
for(i=0;i<s;i++){
printf("\n\t\t ");
for(j=0;j<s;j++)
printf("%-10.3f",o[i][j]);}
for(i=0;i<s;i++)
for(j=0;j<s;j++){
if(o1[i][j]<0)
gotoxy(j*12+2,i+20);
else
gotoxy(j*12+3,i+20);
printf("%-9.5f",o1[i][j]);
gotoxy(10,18);
printf("--TRIU of matrix--");
if(s<4){
gotoxy(48,18);
printf("--TRIL of matrix--");
if(o2[i][j]<0)
gotoxy(j*12+42,i+20);
else
gotoxy(j*12+43,i+20);
printf("%-9.5f",o2[i][j]);}}
int b=i+7;
if(s>3){
gotoxy(15,b+18);
printf("--TRIL of matrix--");
for(i=0;i<s;i++)
for(j=0;j<s;j++){
if(o2[i][j]<0)
gotoxy(j*12+2,i+b+20);
else
gotoxy(j*12+3,i+b+20);
printf("%-9.5f",o2[i][j]);}}
i=b+i+20;
gotoxy(8,i+20);
printf("\n\n\n عؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤ؟ عؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤ؟");
printf("\n ³determinan of matrix= %12.3f³ ³determinan of matrix= %12.3f³ ",h1,h2);
printf("\n ہؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤظ ہؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤظ");
printf("\n\n\n\t عؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤ؟");
printf("\n\t ³ design and make by : pluskid2000@yahoo.com ³ ",h2);
printf("\n\t ہؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤؤ ؤؤؤؤؤؤؤؤظ");
printf("\n\n\n\t would you like to continue?");}
//calculate triU//////////////////////////////////////////////////////////////////////
void calculateU(float c[][10],int s){
float *h=(float*)malloc(sizeof(float));int y=0,k=s;
int register i,j;
while(y<s-1){
for(i=1;i<k;i++){
if(c[y][y]!=0)
h[i-1]=c[y+i][y]/c[y][y];
else{
for(j=0;j<s;j++)
c[y][j]+=c[y+i][j];
h[i-1]=c[y-i][y]/c[y][y];}}
y++;k--;
for(i=0;i<k;i++)
for(j=s-1;j>=0;j--)
c[i+y][j]=c[i+y][j]-h[i]*c[y-1][j];}}
//calculate triL//////////////////////////////////////////////////////////////////////
void calculateL(float c[][10],int s){
float *h=(float*)malloc(sizeof(float));int y=s-1,k=s;
int register i,j;
while(y>0){
for(i=1;i<k;i++){
if(c[y][y]!=0)
h[i-1]=c[y-i][y]/c[y][y];
else{
for(j=0;j<s;j++)
c[y][j]+=c[y-i][j];
h[i-1]=c[y-i][y]/c[y][y];}}
y--;k--;
for(i=0;i<k;i++)
for(j=s-1;j>=0;j--)
c[y-i][j]=c[y-i][j]-h[i]*c[y+1][j];}}
//finish//////////////////////////////////////////////////////////////////////////
//external function
void delay(void){
for(long int l=0;l<1999990;l++);}
void finish(void){
clrscr();int max=20,r=1,e=0,i,j;char k[40]=" Design And Make By:";loop:r--;
for(i=0;i<24;i++)for(j=0;j<max;j++){
gotoxy(j+2*i,j+e);printf("%c",k[i]);
gotoxy(max+2*i,max-1+e);printf(" ");delay();
if(j<max-1)gotoxy(j+2*i,j+e);
printf(" ");}e+=3;
strcpy(k," Hossein Paimard ");
if(r==0)goto loop;
strcpy(k," Pluskid2000@yahoo.com ");
if(r==-1)goto loop;gotoxy(80,50);}

//////////////////////////////\/\/\/\/\/\/\/\/\/\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// pluskid2000@yahoo.com \\
// monday,january23,2006 \\
// 20:02 \\
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\/\/\/\/\/\/\/\/\/\/\//////////////////////////

آبجی
13th April 2010, 03:27 AM
ضرب چند تابع بر حسب s
این برنامه به صورت زیر عمل می کند.
مثلا برای:
(2S^2+1)(5S^3+2S^2+1)(3S^5+7.6S^4+1)
1.تعداد بردار را می گیرد (حداکثر 5 بردار) برای مثال بالا =3
2.درجه بردار اول را می گیرد برای مثال بالا از چپ =2
3.ضرایب بردار اول را می گیرد برای مثال بالا
=2
=0
=1
4.درجه بردارهای بعدی و ضرایب آنها را مانند مراحل 2و3 می گیرد
5.نمایش ضرب تمام بردارها در هم برحسب s



#include<stdio.h>
#include<conio.h>
void compute(float[][50],int[],int,int);
int main(){
int i,v,w=0,e,j,c[5]={0};float s[10][50]={0};clrscr();
printf("\nenter number of vectors:");scanf("%d",&v);
for(i=0;i<v;i++){
printf("\n****************************");
printf("\nenter degree of vector (%d):",i+1);scanf("%d",&c[i]);w+=c[i];
printf("\n*************************");
for(j=c[i];j>=0;j--){
printf("\nenter power of degree %d:",j);scanf("%f",&s[i][j]);}}
compute(s,c,v,w);
getch();return 0;}
//************************************************** **************************
void compute(float s[][50],int deg[],int z,int w){
int i,j,r,e=0,t=0;
r=z-1;
while(r!=0){
for(i=deg[t];i>=0;i--)
for(j=deg[t+1];j>=0;j--)
s[z+e][i+j]+=s[t][i]*s[t+1][j];
deg[z+e]=deg[t]+deg[t+1];t+=2;e++;r--;}
//************************************************** **************************
clrscr();
printf("\n\n\n\n%fs^%d",s[z+e-1][w],w);
for(i=w-1;i>0;i--){
if(s[z+e-1][i]==0);
else{
if(s[z+e-1][i]>0)
printf("+%fs^%d",s[z+e-1][i],i);
else
printf("%fs^%d",s[z+e-1][i],i);}}
if(s[z+e-1][0]<0)
printf("%f",s[z+e-1][0]);
else if(s[z+e-1][0]!=0)
printf("+%f",s[z+e-1][0]);}
//*****************************/\/\/\/\/\/\/\/*****************************//
// hossein paimard //
//*****************************\/\/\/\/\/\/\/\*****************************//

استفاده از تمامی مطالب سایت تنها با ذکر منبع آن به نام سایت علمی نخبگان جوان و ذکر آدرس سایت مجاز است

استفاده از نام و برند نخبگان جوان به هر نحو توسط سایر سایت ها ممنوع بوده و پیگرد قانونی دارد