Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // fir.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <vector>
- #include<cstdlib>
- #include <cstdio>
- #include <ctime>
- using namespace std;
- class czastka
- {
- public:
- int x,y,Fx,Fy;
- czastka(int _x,int _y,int _Fx,int _Fy) {x=_x;y=_y;Fx=_Fx;Fy=_Fy;};
- czastka() {x=0;y=0;Fx=0;Fy=0;};
- };
- vector<czastka> particle;
- void moveParticle()
- {
- // return ;
- int particle_max = particle.size(); //skoro am być tak samo...
- for(int i=0; i<particle_max; i++)
- {
- int nx = particle[i].x + particle[i].Fx;
- int ny = particle[i].y + particle[i].Fy;
- particle[i].x = nx;
- particle[i].y = ny;
- }
- }
- int main()
- {
- int liczba_czastek;
- scanf ("%d",&liczba_czastek);
- particle.resize(liczba_czastek);
- for (int i=0; i<liczba_czastek;i++ )
- particle[i]=czastka(rand(),rand(),rand(),rand());//wypalniamy smieciem
- clock_t start = clock();
- for (int j=1;j<1000;j++)
- moveParticle();
- clock_t end = clock();
- unsigned int akumulator=0;
- for (int i=0; i<liczba_czastek;i++ )
- akumulator+= particle[i].x+particle[i].y; //zbieramy smiecie
- printf("trwało %f %d", ((float)(end-start))/CLOCKS_PER_SEC,akumulator);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement