A Completely responsive pet shop website template with HTML, CSS, Bootstrap, and JavaScript. This is also called free dog breeder website template design and you easily free download it from our website free website create. Free dog breeder Pet Shop Website Design HTML CSS Template
The Internet is a great place to find dog breeders. With so many choices, it can be overwhelming and confusing. This is why there are so many websites that offer free templates for dog breeders to get started. These websites are designed to make it easy for breeders to find the best breeders, start a business, and help them get the word out.
Free dog breeder Pet Shop Website Design HTML CSS Template
Birection array
Often there are problems where say you are at a position in a 2-D array, from there you can go up-down-left-right. Or there is a knight on the chess board, he can be moved in 8 directions, now he has to take the shortest path to one of the positions. Beginner coders make the code size huge because they don’t know a little trick in this kind of problem.
For those who don’t know the direction array trick, their code for this type of problem looks something like this:
int x=5,y=3,row=5,col=5,nx,ny;
nx=x+1; ny = y;
if(nx>=1 && nx<=row && ny>=1 && ny<=col)
{
DO SOMETHING
}
nx=x-1; ny = y;
if(nx>=1 && nx<=row && ny>=1 && ny<=col)
{
DO SOMETHING
}
nx=x; ny=y+1;
……….
……….
……….
In this way, the appearance of the code becomes terrible when writing the same line again and again, and when someone sees the code, he is also in a state of madness! If it can be moved in 8 directions, there is no question. The biggest problem is that if you change in one place, you have to change everywhere.
An improvement would be to make the if(nx>=1 && nx<=row && ny>=1 && ny<=col) line condition a macro. For example:
#define valid(nx,ny) nx>=1 && nx<=row && ny>=1 && ny<=col
Now if(valid) is written. After that, if the tasks of the DO SOMETHING part are also made into a function, the problem will be reduced a bit, now if you change it to an empty macro or function, it will change everywhere. Even then we have to repeatedly check the condition or call the function. For this we will use the direction array. Can be moved in 4 directions means:
1. Adds 1 to current row and adds 0 to current col
2. Adds -1 to current row and adds 0 to current col
3. Add 0 to current row and 1 to current col
4. Add 0 to current row and -1 to current col
That means to move up from x,y position (x,y)+(1,0), to go down (x,y)+(-1,0), same way to go right-left only add with y.
We declare two arrays like this:
int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
fx[] means how much to add to row and fy means how much to add to y. Now the job is very easy:
#define valid(nx,ny) nx>=1 && nx<=row && ny>=1 && ny<=col
int x=5,y=3,row=5,col=5,nx,ny;
for(int k=0;k<4;k++)
{
int nx=x+fx[k]; //Add fx[k] with current row
int ny=y+fy[k]; //Add fy[k] with current col
if(valid(nx,ny)
{
DO SOMETHING;
}
}
If you want to go to 8 the array will look like this:
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
With a little thought, you can write direction arrays for the moves of chess horses as well. This will also work in 3-D, requiring another array named fx[] .
If you want the complete code, you can see this BFS code:
//Problem link:http://acm.timus.ru/problem.aspx?space=1&num=1145
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define pb(x) push_back(x)
#define mem(x,y) memset(x,y,sizeof(x));
#define pii pair<int,int>
#define pmp make_pair
#define uu first
#define vv second
using namespace std;
#define READ(f) freopen(f, “r”, stdin)
#define WRITE(f) freopen(f, “w”, stdout)
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};
int mr,mc,mx=0;
char w[1000][1000];
int d[1000][1000];
int r,c;
void bfs(int x,int y,int dep)
{
mem(d,63);
d[x][y]=0;
queue<pii>q;
q.push(pii(x,y));
while(!q.empty())
{
pii top=q.front(); q.pop();
if(d[top.uu][top.vv]>mx)
{
mx=d[top.uu][top.vv];
mr=top.uu;
mc=top.vv;
}
rep(k,4)
{
int tx=top.uu+fx[k];
int ty=top.vv+fy[k];
if(tx>=0 and tx<r and ty>=0 and ty<c and w[tx][ty]==’.’ and d[top.uu][top.vv]+1<d[tx ][ty])
{
d[tx][ty]=d[top.uu][top.vv]+1;
q.push(pii(tx,ty));
}
}
}
}
int main(){
// READ(“in”);
int sx,sy,cc=0;
cin>>r>>c;
swap(r,c);
rep(i,r)
cin>>w[i];
rep(i,r)
rep(j,c)
if(w[i][j]==’.’){sx=i;sy=j;cc++;}
bfs(sx,sy,0);
mx=0;
bfs(mr,mc,0);
if(cc==1) mx=0;
cout<<mx<<endl;
return 0;
}
This code is just to show the use of direction array, the solution of the problem is yours, the problem asks to find the diameter of the tree.
Happy Coding!
Why should I learn programming?
I woke up in the morning and saw this article on topcoder “If you give a child the same iPhone, he will play Angry Birds day and night, if you teach the child coding, he will create software for the iPhone.” Seeing this great article, I thought I should write something in Bengali about why we should learn programming or coding. This article is a small attempt to interest those who have no or very little knowledge of programming.
Free dog breeder Pet Shop Website Design HTML CSS Template
The computer is an incredibly powerful but mindless machine. One machine can do the work of 50 ordinary men alone but 50 machines cannot do the work of one extraordinary man (Hubbard, Elbert). By learning programming, each of us can become that person who can make this machine speak at will. Programming is simply what you tell the computer to do. Maybe you can say that now the computer does that, when I ask it to play music, it plays it, when I want to play a game, it starts playing with me.
But the fact is that a programmer has already told the computer that if you want to listen to music, it should play it. If he kept saying that if you wanted to play games and advise you to sit down to read, then the computer would have done that, you wouldn’t have had anything to do. A programmer is one whose words make the computer go up and down. It’s a great thing, isn’t it?
But why should you learn programming? The first reason I’ll say before the big talk is because “Programming is a lot of fun!”. The big difference between computers and other devices is that there is no limit to how many things can be done with it. So if you sit down to list how many things you can do if you know programming, it’s hard to finish.
You will see that programming day after day is not boring, you learn something new and interesting almost every day, you can do more things with the discovery of new technologies or you are the one who makes new discoveries! Today you may be writing a function to solve a complex equation, tomorrow you sit down to make an animation with red and blue colors because it doesn’t look good, you can use all your creativity in the world of programming.
They are, in short, a perfect match. – Bill Bryson
Before Download
You must Join our Facebook Group and Subscribe YouTube Channel
All Links in Below:
Join Our FreeWebsiteCreate Facebook Group to get an instant update for projects, templates, design resources, and solutions.
Join Our YouTube Channel & Subscribe with Bell Icon for New Video:
Join Our Official Facebook Page For the Latest updates All Code Projects are Free:
Visit our service page to get premium services.
Free Website Create – HTML CSS, PHP, JavaScript Programming Projects For Free
Follow Us
Thank You,
Before Download
You must Join our Facebook Group and Subscribe YouTube Channel
FreeWebsiteCreate.net tries to provide HTML, CSS, SCSS, JavaScript, React, Android Studio, Java, PHP, Laravel, Python, Django, C#(C Sharp), and ASP.net-related projects 100% free. We try to make learning easier. Free Website Create always tries to give free projects to new learners. Free projects and source code will help to learn quickly.
They can save time and learn more. In this post, we share a free portfolio project website code with HTML and CSS. This free code portfolio contains a single landing page with a responsive design. In this post, we get a free best carpenter and craftsman service website designed by FreeWebsiteCreate with HTML, CSS, Bootstrap, and JavaScript.