# Shkenca > Informatikë dhe Internet > Arti i programimit >  Programimi i simulimit të shiut në C

## doublex

Do te doja te me ndihmonit ne krijimin e nje programi (simulimi i renies se shiut dhe ndikimi i eres ne renien e shiut,i cili behen zhvendosjen anash te pikave te shiut) ne gjuhen C i cili te paraqitet
ne nje ekran me 25x80,i cili te kerkoje ne filiim shpejtesin e eres dhe drejtimin e saj.me sa kam kuptuar behet me ane te vektoreve ku vektori i pare mbushet me ane te funksionit rand() dhe pastaj ky vektor zbret me poshte e keshtu me radhe sipas nje kohe qe percaktohet nga funksioni delay().do t'iu isha shume mirnjohes po te me ndihmonit.

----------


## P@R4nOi@C_LorD

Me duhej dhe mua kjo detyre.
Edhe ndonji link me shembull anglisht do ndihmonte.

----------


## valdetshala

shikoni ketu pak:
http://www.planet-source-code.com/vb...=2749&lngWId=3

----------


## P@R4nOi@C_LorD

Valdet falemiderit. Po ptai ndonjeri ndonje link tjeter eshte i lutur ta postoj (vetem te ket lidhje me shiun).
doublex ca  dege je , ca grupi a , b apo c?

----------


## doublex

une studioj per elektronike dhe jam ne grupin A.duke pasur besim ne profesionalizmin tuaj shpresoj te me ndihmoni

----------


## valdetshala

shikoni edhe ketu  http://en.pudn.com/downloads57/sourc...202333_en.html   sepse per ta shkarkuar nje file me kerkon te regjistrohem por nuk kam kohe sonte  fajlli eshte Rain.rar

----------


## P@R4nOi@C_LorD

doublex atehere jemi me nje klas. Si e ke emrin?

----------


## P@R4nOi@C_LorD

Valdet faleminderit per linket po kjo e fundit kerkonte user premium per shkarkimin.

----------


## valdetshala

provoni kete kode nje here

#include  
#include  
#include  
#include  
#include  
#include  
#define LEN sizeof(struct rainDrop) 

int rainDropNumber=60; 
int downSpeed=20; 
struct rainDrop *head; 

struct rainCircle 
{ 
	int x; 
	int y; 
	int r; 
	int curR; 
	int rainCircleStep; 
}; 

struct rainDrop 
{ 
	int startX; 
	int startY; 
	int endY; 
	int curX; 
	int curY; 
	int rainColor; 
	int rainLineStep; 
	int rainLineLength; 
	int status; 
	struct rainCircle water; 
	struct rainDrop *next; 
}; 

void initgraphics(void) 
{ 
	int gmode,gdriver; 
	gdriver=DETECT; 
	initgraph(&gdriver,&gmode,""); 
} 

struct rainDrop *creatDrop(void) 
{ 
	struct rainDrop *p; 
	p=(struct rainDrop *)malloc(LEN); 
	p->startX=rand()%640; 
	p->startY=rand()%430; 
	p->endY=430+rand()%50; 
	p->curX=p->startX; 
	p->curY=p->startY; 
	p->rainLineStep=8; 
	p->rainColor=rand()%15+1; 
	p->rainLineLength=rand()%10+10; 
	p->status=0; 
	p->water.x=p->startX; 
	p->water.y=p->endY; 
	p->water.r=rand()%40; 
	p->water.curR=rand()%2; 
	p->water.rainCircleStep=rand()%2+1; 
	p->next=NULL; 
	return(p); 
} 

void recreatDrop(struct rainDrop *p) 
{ 
	p->startX=rand()%640; 
	p->startY=rand()%430; 
	p->endY=430+rand()%50; 
	p->curX=p->startX; 
	p->curY=p->startY; 
	p->rainLineStep=8; 
	p->rainColor=rand()%15+1; 
	p->rainLineLength=rand()%10+10; 
	p->status=0; 
	p->water.x=p->startX; 
	p->water.y=p->endY; 
	p->water.r=rand()%40; 
	p->water.curR=rand()%2; 
	p->water.rainCircleStep=rand()%2+1; 
} 

void creatRain(void) 
{ 
	struct rainDrop *p1,*p2; 
	int i; 
	p1=p2=creatDrop(); 
	head=p1; 
	for(i=0;inext=p2; 
		p1=p2; 
	} 
} 

void updateRainLineData(struct rainDrop *p) 
{ 
	if(p->rainLineStep%5==0) 
		p->rainLineStep++; 
	p->curY+=p->rainLineStep; 
	p->startY=p->curY-p->rainLineLength; 
} 

void drawRainLine(struct rainDrop *p) 
{ 
	setcolor(p->rainColor); 
	line(p->startX,p->startY,p->curX,p->curY); 
} 

void clearRainLine(struct rainDrop *p) 
{ 
	setcolor(BLACK); 
	line(p->startX,p->startY,p->curX,p->curY); 
} 

void rainDropDown(struct rainDrop *p) 
{ 
	if(p->curY>=p->endY) 
	{ 
		clearRainLine(p); 
		p->status=1; 
	} 
	else 
	{ 
		clearRainLine(p); 
		updateRainLineData(p); 
		drawRainLine(p); 
	} 
} 

void updateRainCircleData(struct rainDrop *p) 
{ 
	p->water.curR+=p->water.rainCircleStep; 
} 

void drawRainCircle(struct rainDrop *p) 
{ 
	setcolor(p->rainColor); 
	circle(p->water.x,p->water.y,p->water.curR); 
} 

void clearRainCircle(struct rainDrop *p) 
{ 
	setcolor(BLACK); 
	circle(p->water.x,p->water.y,p->water.curR); 
} 

void fallToWater(struct rainDrop *p) 
{ 
	if(p->water.curR>=p->water.r) 
	{ 
		clearRainCircle(p); 
		recreatDrop(p); 
	} 
	else 
	{ 
		clearRainCircle(p); 
		updateRainCircleData(p); 
		drawRainCircle(p); 
	} 
} 

void rain(void) 
{ 
	struct rainDrop *p; 
	p=head; 
	while(!kbhit()) 
	{ 
		if(p==NULL) 
			p=head; 
		else 
		{ 
			if(p->status==0) 
			rainDropDown(p); 
		else 
			fallToWater(p); 
		} 
		delay(downSpeed); 
		p=p->next; 
	} 
} 

void clearAll(void) 
{ 
	struct rainDrop *p,*pf; 
	p=head; 
	while(p!=NULL) 
	{ 
		pf=p; 
		p=p->next; 
		free(pf); 
	} 
	closegraph(); 
} 

main() 
{ 
	printf("Input rainDrop Number:"); 
	scanf("%d",&rainDropNumber); 
	printf("Input down speed:"); 
	scanf("%d",&downSpeed); 
	randomize(); 
	initgraphics(); 
	creatRain(); 
	rain(); 
	clearAll(); 
}

----------


## P@R4nOi@C_LorD

Valdet cfare librarish duhen ber include se te kod qe ke postuar nuk jan.

----------


## P@R4nOi@C_LorD

doublex nuk me the emrin.

----------


## valdetshala

kliko edhe nje here por krejt poshte ne fund te kesaj faqe
http://en.pudn.com/downloads40/sourc...136729_en.html  i ke listat.

----------


## P@R4nOi@C_LorD

doublex pergjigje nuk morem qe nuk morem , te pakten me thuaj ca e ke emirn.

----------


## doublex

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<ctime>
#include<windows.h>
int kbhit(void);
int main()
{int mat[25][80];
 int i,j,nr=0,d,n=0,k=0,m=0,o=0,p=0,v;
 char c;
 FILE *pikashiu;
 provo:
 printf("--------------------------------------------------------------------------------\n");
 printf("                          /* Simulimi i renies se shiut.c*/ \n");
 printf("--------------------------------------------------------------------------------\n");
 printf("                - Jepni drejtimin e eres,lindje apo perendim(l/p) \n");
 printf("--------------------------------------------------------------------------------\n");
 printf("                                   Ose pa ere(j)\n");
 printf("--------------------------------------------------------------------------------\n");
 scanf("%c",&c);
 if((c!='j')&&(c!='l')&&(c!='p'))
 {
 printf("--------------------------------------------------------------------------------\n");
 printf("                       Ju shtypet alternative jo te sakte.\n");
 printf("--------------------------------------------------------------------------------\n");
 printf("                                   Provo perseri\n");
  printf("--------------------------------------------------------------------------------\n");
 Sleep(1000);
 system("CLS");
 goto provo;}
 else if(c=='j')
 {goto pa_ere;}
 else{
 v_eres:
 printf("--------------------------------------------------------------------------------\n");
 printf("                  -  Jepni shpejtesine e eres(1-7).\n"); 
 printf("--------------------------------------------------------------------------------\n");
 scanf("%d",&v);
 if((v!=1)&&(v!=2)&&(v!=3)&&(v!=4)&&(v!=5)&&(v!=6)&  &(v!=7))
 { printf("--------------------------------------------------------------------------------\n");
 printf("                      Ju shtypet alternative jo te sakte.\n");
 printf("--------------------------------------------------------------------------------\n");
 printf("                                 Provo perseri\n");
  printf("--------------------------------------------------------------------------------\n");
 Sleep(1000);
 system("CLS");
 goto v_eres;}
 pa_ere:
 printf("--------------------------------------------------------------------------------\n");
 printf("                  -  Jepni shpejtesine e renies se shiut(1-5)\n"); 
 printf("--------------------------------------------------------------------------------\n");
 scanf("%d",&d);
 if((d!=1)&&(d!=2)&&(d!=3)&&(d!=4)&&(d!=5))
 {
 printf("                      Ju shtypet alternative jo te sakte.\n");
 printf("--------------------------------------------------------------------------------\n");
 printf("                                 Provo perseri\n");
 printf("--------------------------------------------------------------------------------\n");
 Sleep(1000);
 system("CLS");
 goto pa_ere;}
 system("CLS");
 srand(time(0));

 for(i=0;i<25;i++)
 {for(j=0;j<80;j++)
  {mat[i][j]=rand()%2;
  }
 }


if(c=='j')
  {  while(!kbhit())
   {for(i=0;i<25;i++)
    {for(j=0;j<80;j++)
     {if(mat[i][j]==0)
      printf(" ");
     else if(mat[i][j]==1)
     printf(".");
     }Sleep(50);
   }  for(j=0;j<15;j++)
            {if (mat[24][j]==1)
            k++;
           }
            for(j=16;j<31;j++)
            {if (mat[24][j]==1)
            m++;
           }
            for(j=32;j<47;j++)
            {if (mat[24][j]==1)
            n++;
           }
            for(j=48;j<63;j++)
            {if (mat[24][j]==1)
            o++;
           }
            for(j=64;j<80;j++)
            {if (mat[24][j]==1)
            p++;
           }Sleep(((6)-d)*100); 

  }
 } 
else
   {
     while(!kbhit())
      {for(i=0;i<25;i++)
       {for(j=0;j<80;j++)
        {if(mat[i][j]==0)
         printf(" ");
         else if(mat[i][j]==1)
          printf(".");
         }
        }

        if(c=='p')
           { for(i=0;i<24;i++)
             {for(j=0;j<80;j++)
              {mat[i+1][j+v]=mat[i][j];
               }
              }
             }
         if(c=='l')
           { for(i=0;i<24;i++)
            {for(j=0;j<80;j++)
             {mat[i+1][j-v]=mat[i][j];
              }
             }
            }
              for(j=0;j<15;j++)
            {if (mat[24][j]==1)
            k++;
           }
            for(j=16;j<31;j++)
            {if (mat[24][j]==1)
            m++;
           }
            for(j=32;j<47;j++)
            {if (mat[24][j]==1)
            n++;
           }
            for(j=48;j<63;j++)
            {if (mat[24][j]==1)
            o++;
           }
            for(j=64;j<80;j++)
            {if (mat[24][j]==1)
            p++;
           }Sleep(((6)-d)*30);


         } 

        } 
         pikashiu = fopen("shiu.txt","w"); 
         fprintf( pikashiu,"Nr. i pikave te shiut eshte per secilen zone eshte\n ");
         fprintf( pikashiu,"Zona e pare   =%d\n ",k);
         fprintf( pikashiu,"Zona e dyte   =%d\n ",m);
         fprintf( pikashiu,"Zona e trete  =%d\n ",n);
         fprintf( pikashiu,"Zona e katert =%d\n ",o);
         fprintf( pikashiu,"Zona e peste  =%d\n ",p);
         fclose( pikashiu);
         getchar();
         getchar();
        }}

----------


## P@R4nOi@C_LorD

doubleX klasa ime nuk kishte kte kod , dmth nuk je te A-ja nejse varja.

----------


## doublex

une jam per informatike grupi b dhe kodi eshte i imi.

----------


## danjeli

E mo cuna do beheni ing.
................................

----------


## Evil-Queen

ja politekniku ktej  :buzeqeshje:  ja dolem si ja dolem me ate shiun

----------


## mjelmaL

Pershendetje! Jame fillestar ne programim dhe po perpiqem ne menyre autodidakte.
kam hasur pak veshtiresi per te kuptuar nje pjese te nje ushtrimi. ushtrimi eshte trekendeshi i paskalit dhe eshte i shkruar ne C++. Me poshte po ju paraqes ushtrimin e zgjidhur dhe pjesen ku kam veshtiresi per ta kuptuar.

#include<iostream>
using namspace std;
main()
{const char car='*';
int NL; // numeri linjave
int nrl; // numeruesi i linjave
int ns; // numeri "spaces" perpara yllit
int j;

cout<< "Jepni numerin e linjave: "
cin>> NL;
for (nrl=0; nrl<NL; nrl++)
{ns=NL-nrl-1;  // ajo qe nuk kupoje eshte perllogaritja e hapesirave para *
for(j=0; j<ns; j++) cout<<' ' ; 
for(j=0; j<2*nrl+1; j++) cout << car;
cout<< '\n');
}

Pra sic e permenda pak me larte, kam hasur veshtiresi tek perllogaritja e hapesires. Nuk arrije ta kuptoje pse hapesira llogaritet NL-nrl-1.
Mbase mund t'iu duket fare i thjeshte si problem, por gjithesesi te gjithe kemi kaluar nga ketu kur kemi nisur programimin. Faleminderit per ndihmen tuaj! ML

----------


## hot_prinz

*mungoi mundesia e vendosjes se fotos gjate ndryshimit te postimit!

----------

