|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Hi all hacking members I am new join
|
|
|
|
|
Wrong site: this is not a hacking site, and we do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
You will get no help hacking anything here.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
That's why I didn't add a report in S&A.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What's wrong with hacking? I had a parrot doing it all the time!
|
|
|
|
|
In the words of Biff Tannen: "I think you've got the wrong car, McFly."
|
|
|
|
|
I like hacking. That's one of the best ways to learn how things work. Do you have a question?
|
|
|
|
|
Learning how to exploit a vulnerability teaches not how to code.
Been doing development for over 20 years, and a "little" paranoid. Sporting my own hostfile and delivering updates to multiple hosts.
I like education.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Learning how to exploit a vulnerability teaches not how to code. Sure it can.
Just like SQL injection. That's hacking but we talk about it all the time. Hacking is a good way to learn how things work.
|
|
|
|
|
20212 wrote: Sure it can. No, it doesn't; it teaches nothing about patterns, not even about security, it only shows where breaches are.
20212 wrote: Just like SQL injection Thank you for proving my point.
20212 wrote: That's hacking but we talk about it all the time. Hacking is a good way to learn how things work. It's a way of learning to know about weaknesses, not about how things work. Here an analogy for ya; you claim you can run an atomic power plant, because you know an unguarded door. In my opinion, you not even less qualified than any real programmer, but a liability.
And you know you are; that's why I post under my real name, and you don't dare too.
--edit
From a real criminal; do you have any questions?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Thank you for proving my point. I don't think you understand your point then.
If all we told people is to use parameterized queries but did not explain why, the lesson would not be learned as well. Explaining how non-parameterized queries can allow someone to hack your db is magnitudes more valuable than just telling them to use parameters.
Eddy Vluggen wrote: that's why I post under my real name, and you don't dare too. 1. You can't prove that it's your real name.
2. You can't prove this is not my real name.
|
|
|
|
|
20212 wrote: I don't think you understand your point then. Not my problem, is it?
20212 wrote: If all we told people is to use parameterized queries but did not explain why, the lesson would not be learned as well. Explaining how non-parameterized queries can allow someone to hack your db is magnitudes more valuable than just telling them to use parameters. Again, thanks for proving my point
20212 wrote: 1. You can't prove that it's your real name. I can, there's a photograph on here from me. Look it up. No, no record government linking me to that, I not that much of a fool.
20212 wrote: 2. You can't prove this is not my real name. Easy, that's not even a legal name; you're not allowed to name children like that.
I been a developer for over 20 years. Been concerned with security for the same time. We "know a bit" about the subject
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
20212 wrote: Just like SQL injection. I am so old that I find the very idea of SQL injection completely crazy. Why would anyone even get close to the idea of passing SQL code ahead, without parsing it and consider it against authorization restrictions?
I know. "Because it would reduce performance". So then you could make two versions of your SQL based application: One HighPeformance version to use when benchmarking or comparing against alternatives. When you boost multiplatform and high availability, there is another, "safe" version with all the flexibility and functionality ruining performance, but beneficial in a lot of other ways.
|
|
|
|
|
trønderen wrote: I am so old that I find the very idea of SQL injection completely crazy. Why would anyone even get close to the idea of passing SQL code ahead, without parsing it and consider it against authorization restrictions? Because often there's none such restriction. Looking at you VB programmers.
trønderen wrote: I know. "Because it would reduce performance" Not in any way. So proven you don't know.
The rest of your drivel I not gonna answer to. You entitled to your petty opinions, and that's why I'm paid more.
Any other questions?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Excellent when you are in Cairns we can have a game of golf, I'm only an average hacker though!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
If you meant "mincing meat", then yes.
Otherwise, BGS9.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello everyone. I am just a beginner programmer.
I am learning recursion and dynamic programming.
I realized that even for Fibonacci numbers, recursion is not suitable - and there you need to use dynamic programming.
:thumbsup:
Well, I looked at the tutorials, it's good when you can deduce the recurrent relation and then everything is clear...
But if we cannot do it, how then?
????
For example, I took the famous task "Knight's tour" and solved it using recursion.
using System;
namespace KnightChess
{
class Field
{
public int index { get; set; }
public Field(int _index)
{
index = _index;
}
}
class Board
{
int height;
int width;
public (int, int) curKnightPos;
int value;
public Field[,] boardArr;
public static bool CanMoveKnight1(Board Board)
{
return (Board.width > Board.curKnightPos.Item1 + 1) && (Board.height > Board.curKnightPos.Item2) &&
(Board.boardArr[Board.curKnightPos.Item1 + 1, Board.curKnightPos.Item2].index == -1);
}
public static Board MoveKnight1(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 += 2;
Transformed.curKnightPos.Item2++;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight2(Board Board)
{
return (Board.width > Board.curKnightPos.Item1) && (Board.height > Board.curKnightPos.Item2 + 1) &&
(Board.boardArr[Board.curKnightPos.Item1, Board.curKnightPos.Item2 + 1].index == -1);
}
public static Board MoveKnight2(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1++;
Transformed.curKnightPos.Item2 += 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight3(Board Board)
{
return (Board.curKnightPos.Item1 > 1) && (Board.height > Board.curKnightPos.Item2 + 1) &&
(Board.boardArr[Board.curKnightPos.Item1 - 2, Board.curKnightPos.Item2 + 1].index == -1);
}
public static Board MoveKnight3(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1--;
Transformed.curKnightPos.Item2 += 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight4(Board Board)
{
return (Board.curKnightPos.Item1 > 2) && (Board.height > Board.curKnightPos.Item2) &&
(Board.boardArr[Board.curKnightPos.Item1 - 3, Board.curKnightPos.Item2].index == -1);
}
public static Board MoveKnight4(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 -= 2;
Transformed.curKnightPos.Item2++;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight5(Board Board)
{
return (Board.curKnightPos.Item1 > 2) && (Board.curKnightPos.Item2 > 1) &&
(Board.boardArr[Board.curKnightPos.Item1 - 3, Board.curKnightPos.Item2 - 2].index == -1);
}
public static Board MoveKnight5(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 -= 2;
Transformed.curKnightPos.Item2--;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight6(Board Board)
{
return (Board.curKnightPos.Item1 > 1) && (Board.curKnightPos.Item2 > 2) &&
(Board.boardArr[Board.curKnightPos.Item1 - 2, Board.curKnightPos.Item2 - 3].index == -1);
}
public static Board MoveKnight6(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1--;
Transformed.curKnightPos.Item2 -= 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight7(Board Board)
{
return (Board.width > Board.curKnightPos.Item1) && (Board.curKnightPos.Item2 > 2) &&
(Board.boardArr[Board.curKnightPos.Item1, Board.curKnightPos.Item2 - 3].index == -1);
}
public static Board MoveKnight7(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1++;
Transformed.curKnightPos.Item2 -= 2;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static bool CanMoveKnight8(Board Board)
{
return (Board.width > Board.curKnightPos.Item1 + 1) && (Board.curKnightPos.Item2 > 1) &&
(Board.boardArr[Board.curKnightPos.Item1 + 1, Board.curKnightPos.Item2 - 2].index == -1);
}
public static Board MoveKnight8(Board Board)
{
Board Transformed = new Board(Board);
Transformed.curKnightPos.Item1 += 2;
Transformed.curKnightPos.Item2--;
Transformed.boardArr[Transformed.curKnightPos.Item1 - 1, Transformed.curKnightPos.Item2 - 1].index = ++Transformed.value;
return Transformed;
}
public static void Print(Board Board)
{
for (int i = Board.width - 1; i >= 0; i--)
{
for (int j = 0; j < Board.height; j++)
{
Console.Write(Board.boardArr[i, j].index + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
public static bool isFull(Board Board)
{
foreach(var el in Board.boardArr)
{
if (el.index == -1)
{
return false;
}
}
return true;
}
public Board(Board Board)
{
height = Board.height;
width = Board.width;
curKnightPos = Board.curKnightPos;
value = Board.value;
boardArr = new Field[width, height];
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
boardArr[i, j] = new Field(Board.boardArr[i, j].index);
}
}
}
public Board(int _height, int _width, (int, int) _curKnightPos)
{
height = _height;
width = _width;
curKnightPos = _curKnightPos;
value = 1;
boardArr = new Field[_width, _height];
for(int i = 0; i < _width; i++)
{
for (int j = 0; j < _height; j++)
{
boardArr[i, j] = new Field(-1);
}
}
boardArr[_curKnightPos.Item1 - 1, _curKnightPos.Item2 - 1].index = 1;
}
}
class Program
{
static void Main(string[] args)
{
#region input and define
Console.WriteLine("Please enter board's width");
string temp;
temp = Console.ReadLine();
int width;
bool success;
success = int.TryParse(temp, out width);
if (!success)
{
Console.WriteLine("Width be natural a number");
return;
}
Console.WriteLine("Please enter board's height");
temp = Console.ReadLine();
int height;
success = int.TryParse(temp, out height);
if (!success)
{
Console.WriteLine("Height be natural a number");
return;
}
Console.WriteLine("Please enter board's curKnightPosX");
temp = Console.ReadLine();
int curKnightPosX;
success = int.TryParse(temp, out curKnightPosX);
if (!success)
{
Console.WriteLine("CurKnightPosX be natural a number");
return;
}
Console.WriteLine("Please enter board's curKnightPosY");
temp = Console.ReadLine();
int curKnightPosY;
success = int.TryParse(temp, out curKnightPosY);
if (!success)
{
Console.WriteLine("CurKnightPosY be natural a number");
return;
}
if ((curKnightPosX > width) || (curKnightPosY > height))
{
Console.WriteLine("curKnightPos out of range");
return;
}
Board Board = new Board(height, width, (curKnightPosX, curKnightPosY));
#endregion
GetTransformsMap(Board);
Console.ReadKey();
}
private static void GetTransformsMap(Board board)
{
if (!Board.CanMoveKnight1(board) && !Board.CanMoveKnight2(board) && !Board.CanMoveKnight3(board) && !Board.CanMoveKnight4(board) &&
!Board.CanMoveKnight5(board) && !Board.CanMoveKnight6(board) && !Board.CanMoveKnight7(board) && !Board.CanMoveKnight8(board))
{
if (Board.isFull(board))
{
Board.Print(board);
}
}
if (Board.CanMoveKnight1(board))
{
GetTransformsMap(Board.MoveKnight1(board));
}
if (Board.CanMoveKnight2(board))
{
GetTransformsMap(Board.MoveKnight2(board));
}
if (Board.CanMoveKnight3(board))
{
GetTransformsMap(Board.MoveKnight3(board));
}
if (Board.CanMoveKnight4(board))
{
GetTransformsMap(Board.MoveKnight4(board));
}
if (Board.CanMoveKnight5(board))
{
GetTransformsMap(Board.MoveKnight5(board));
}
if (Board.CanMoveKnight6(board))
{
GetTransformsMap(Board.MoveKnight6(board));
}
if (Board.CanMoveKnight7(board))
{
GetTransformsMap(Board.MoveKnight7(board));
}
if (Board.CanMoveKnight8(board))
{
GetTransformsMap(Board.MoveKnight8(board));
}
}
}
}
We enter the size of the board and the coordinates of the initial position of the knight - after which the calculation takes place.
Video attached
DropMeFiles – free one-click file sharing service[^]
As you can see from the video for 8x8, we get one of the solutions in a reasonable amount of time.
But if the task is to get all the solutions?
Even for 6x6 it already freezes - everything depends on memory, I have 8GB of RAM.
:) :) :)
Help, how can this example be optimized to get ALL solutions?
Will it change anything if rewritten in C ++ or there in python?
|
|
|
|
|
I'm not getting it: How could anyone even consider doing the Fibonacci sequence recursively? For printing it backwards?
|
|
|
|
|
You really surprised me. I watched a lot of tutorials - on recursion and almost everyone has an example with Fibonacci
static int fib(int n, int a , int b )
{
if (n == 0)
return a;
if (n == 1)
return b;
return fib(n - 1, b, a + b);
}
|
|
|
|
|
Kari Trust wrote: I watched a lot of tutorials - on recursion and almost everyone has an example with Fibonacci I can see a single reason for using fibonacci to illustrate recursion: To show that it isn't needed. The keyword is tail recursion.
Certainly, a good compiler will detect tail recursion and save stack space and call overhead, generating a simple jump to the top of the function (after fixing up the parameter block, of course), changing the recursion to an iteration. You might as well do that yourself ... unless, of course, you are so deeply into recursive thinking that you find it hard to consider fibonacci anything but recursive. (I can imagine mathematicians that are that way, but not many programmers!
To me, the obvious way to write a fibonacci-function would be (I consider the sequence to start with 0, labeled the 0th fibonacci number - some people argue details):
static int fib(int n) {
if (n < 2) return n;
int prev = 1;
int fibn = 1;
for (int iteration = 2; iteration < n; iteration++) {
int fibnext = fibn + prev;
prev = fibn;
fibn = fibnext;
}
return fibn;
}
Bonus sidetrack (or is it?):
If you want to make sure that you master recursion, terminating conditions in particular, try this little exercise: Make a console program with recursive function that for each call writes an output line on the console of RecursionDepth number of spaces, followed by an asterisk (and a newline).
If the main program calls this function with arguments NumberOfTeeth, BladeWidth, ToothLength, the output should look like a sawblade; the recursion goes to the maximum recursion depth, ToothLength. Then it returns to BladeWidth recursion depth, before it again recurses to ToothLength depth a second time, and repeats this for at total of NumberOfTeeth dives into the maximum depth, before finally returning to the main program.
If you are a seasoned recursioner, maybe you will find this problem trivial (in that case, forward it to your students or junior programmers!) I have never ever seen anyone getting this perfectly right on the first try, though! Most programmers give it a first try, then they curse before making the first correction, then they re-curse before making a second correction, ... The cursing often goes to the maximum depth of re-cursing before they get it right 
modified 6hrs 20mins ago.
|
|
|
|
|
I tested my application in an another computer. Sometimes when I hit username/password to enter the main menu, it crashes. I run it again and there is no problem. Sometimes when I change input language in order to type inside a Textbox, it crashes. I used Windows Event to find the reason. I have used an analog clock and an special Font inside my application.
Application: DataGridView.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at System.Drawing.SafeNativeMethods+Gdip.GdipDrawString(System.Runtime.InteropServices.HandleRef, System.String, Int32, System.Runtime.InteropServices.HandleRef, System.Drawing.Internal.GPRECTF ByRef, System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef)
at System.Drawing.Graphics.DrawString(System.String, System.Drawing.Font, System.Drawing.Brush, System.Drawing.RectangleF, System.Drawing.StringFormat)
at System.Windows.Forms.Label.OnPaint(System.Windows.Forms.PaintEventArgs)
at System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs, Int16)
at System.Windows.Forms.Control.WmPaint(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Label.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
Faulting application name: DataGridView.exe, version: 1.0.0.0, time stamp: 0xc2801969
Faulting module name: gdiplus.dll, version: 10.0.19041.789, time stamp: 0x198e190d
Exception code: 0xc000041d
Fault offset: 0x00030ec9
Faulting process id: 0x980
Faulting application start time: 0x01d70ce394d6e863
Faulting application path: D:\Softwares\PMinfo\DataGridView.exe
Faulting module path: C:\WINDOWS\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.789_none_429ddec08a8f10c1\gdiplus.dll
Report Id: 25065017-745c-4f6b-8d20-a6d15ce398b1
Faulting package full name:
Faulting package-relative application ID:
modified 3 days ago.
|
|
|
|
|
It might be helpful if you define "analog clock" more clearly. Are you using an over-ridden Paint event in your app ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
I didn't make it by myself (I have a tutorial about it) and for shortage of time, I used a dll reference and its corresponding component. I cannot see its code.
I used a special font which does not exist in Windows by default.
|
|
|
|
|