|
Rather than me answering this question I would suggest you to read here[^] and here[^]. And if this doesn't help then try this[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Override OnCancel Function.
|
|
|
|
|
Chandru080 wrote: Override OnCancel Function.
Which will prevent the dialog from being closed while the cancel button is clicked as well. The previous answer given to the OP was better.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
dear sir
i need a high speed method to make 4 image from one, that the first image have for example 2048*1536 pixel, and the four made is each 1024*768 , so i use the getpixel and setpixel method that is too slow :
vb.net code ::
For y = 0 To picy.Height - 1 Step 2
For x = 0 To picy.Width - 1 Step 2
pic(0).SetPixel(Int(x / 2), Int(y / 2), picy.GetPixel(x, y))
pic(1).SetPixel(Int(x / 2), Int(y / 2), picy.GetPixel(x + 1, y))
pic(2).SetPixel(Int(x / 2), Int(y / 2), picy.GetPixel(x + 1, y + 1))
pic(3).SetPixel(Int(x / 2), Int(y / 2), picy.GetPixel(x, y + 1))
Next x
Next y
please help me to find a very faster method in any languages, vc++ or vb or vc# or others , its not important i need a fast method,
thank you for attentions and cooperations.
|
|
|
|
|
Mortezai wrote: please help me to find a very faster method in any languages, vc++ or vb or vc# or others , its not important i need a fast method,
|
|
|
|
|
You may use GetDIBBits[<a href="http://msdn.microsoft.com/en-us/library/dd144879(VS.85).aspx" target="_blank" title="New Window">^</a>]/SetDIBBits[<a href="http://msdn.microsoft.com/en-us/library/dd162973(VS.85).aspx" target="_blank" title="New Window">^</a>] for direct access to bitmap memory, I do this way in my DLL [^] , you may have a look at the source code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
#include <iostream>
using namespace std;
class Test
{
public:
Test()
{
}
int GetValue()
{
return 2;
}
};
int main()
{
Test* test = new Test();
cout << test->GetValue() << endl;
//test = NULL;
delete test;
cout << test->GetValue() << endl;
system("pause");
return 0;
}
Output:
2
2
I'm a beginer.
|
|
|
|
|
This works because executing GetValue doesn't access any part of a Test object. The function is resolved at compile time. It doesn't access any data members, so the fact that you've deleted the object doesn't affect the execution of the code.
But even though this case works, don't do this in production code or anything...please.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well i got it,and thank you for your help.
|
|
|
|
|
Check this:
class Test
{
int p;
public:
Test()
{
p=2;
}
int GetValue()
{
return p;
}
~Test()
{
}
};
int main()
{
Test* t1 = new Test();
cout << t1->GetValue() <<endl;
delete t1;
t1=NULL;
cout <<t1->GetValue()<<endl;
system("pause");
return 0;
}
Beware of the consequences of writing this type of code that you wrote
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
If you are using Visual Studio 2008, you may try
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::endl;
class Test
{
public:
Test()
{
}
int GetValue()
{
return 2;
}
};
int main()
{
Test* test = new Test();
cout << test->GetValue() << endl;
//test = NULL;
delete test;
cout << test->GetValue() << endl;
system("pause");
return 0;
}
1. add the "#include "stdafx.h"" before "include <iostream>"
2. add the "using std::cout; using std::endl;"
|
|
|
|
|
I consider the second GetValue would return a weird number, but it works to be 2.
now i have got the answer. Thank you for your attention.
|
|
|
|
|
It will even work without ever calling the new operator.
Test* test = NULL;
test->GetValue();
Stuart gave you the reason for that.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
<code><pre><big><b>
Dear Sirs And Madams :
it is an Acm programming competition Questions in year 2004-2005 . could you please solve problems is question ? I Wan't C++ Source Code program About this questions OR Problems . thank you for your prompt attention to this matter
your faithfully.
-----------------------------------------
29th ACM International Collegiate
Sponsored by
Programming Contest, 2004-2005
Sharif Preliminary Contest
Sharif University of Technology, 28 Oct. 2004
Problem B
(Program filename: B.CPP, B.DPR, B.PAS or B.java)
Parallelogram Counting
There are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose
vertices lie on these points. In other words, find the number of 4-element subsets of these points that can be written as
{A, B, C, D} such that AB || CD, and BC || AD. No four points are in a straight line.
Input (filename: B.IN)
The first line of the input file contains a single integer t (1 £ t £ 10), the number of test cases. It is followed by the input
data for each test case.
The first line of each test case contains an integer n (1 £ n £ 1000). Each of the next n lines, contains 2 space-separated
integers x and y (the coordinates of a point) with magnitude (absolute value) of no more than 1000000000.
Output (Standard Output)
Output should contain t lines.
Line i contains an integer showing the number of the parallelograms as described above for test case i.
Sample Input
2
6
0 0
2 0
4 0
1 1
3 1
5 1
7
-2 -1
8 9
5 7
1 1
4 8
2 0
9 8
Sample Output
5
6
----------------------------------------------------------------------------------------------------------------------
Problem B-Page 1 of 1
28th ACM International Collegiate
Sponsored by
Programming Contest, 2003-2004
Sharif Preliminary Contest
Sharif University of Technology, 14 Nov. 2003
Problem C
(Program filename: C.CPP or C.PAS or C.DPR or C.java)
Toy Storage
Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them.
They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply
throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore.
Reza's parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps
throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this
from the top:
We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions
have t, toys.
Input (filename: C.IN)
The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of
cardboards to form the partitions is n (0< n £ 1000) and the number of toys is given in m (0<m £ 1000). The
coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The
following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates
(Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists
of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a
cardboard.
A line consisting of a single 0 terminates the input.
Output (filename: C.OUT)
For each box, first provide a header stating “Box”
on a line of its own. After that, there will be one line of output per
count (t> 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of
partitions containing t toys. Output will be sorted in ascending order of t for each box.
Sample Input
4 10 0 10 100 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0
4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0
Sample Output
Box
2: 5
Box
1: 4
2: 1
----------------------------------------------------------------------
29th ACM International Collegiate
Sponsored by
Programming Contest, 2004-2005
Sharif Preliminary Contest
Sharif University of Technology, 28 Oct. 2004
Problem D
(Program filename: D.CPP, D.DPR, or D.java)
Software Company
A software developing company has been assigned two programming projects. As
both projects are within the same contract, both must be handed in at the same
time. It does not help if one is finished earlier.
This company has n employees to do the jobs. To manage the two projects more
easily, each is divided into m independent subprojects. Only one employee can
work on a single subproject at one time, but it is possible for two employees to
work on different subprojects of the same project simultaneously.
Our goal is to finish the projects as soon as possible.
Input (filename: D.IN)
The first line of the input file contains a single integer t (1 £ t £ 11), the
number of test cases, followed by the input data for each test case. The first
line of each test case contains two integers n (1 £ n £ 100), and m (1 £ m £
100). The input for this test case will be followed by n lines. Each line
contains two integers which specify how much time in seconds it will take for
the specified employee to complete one subproject of each project. So if the
line contains x and y, it means that it takes the employee x seconds to complete
a subproject from the first project, and y seconds to complete a subproject from
the second project.
Output (Standard Output)
There should be one line per test case containing the minimum amount of time in
seconds after which both projects can be completed.
Sample Input
1
3 20
1 1
2 4
1 6
Sample Output
18
Problem D -Page 1 of 1
29th ACM International Collegiate
Sponsored by
Programming Contest, 2004-2005
Sharif Preliminary Contest
Sharif University of Technology, 28 Oct. 2004
----------------------------------------------------------------------
Problem F
(Program filename: F.CPP, F.DPR, or F.java)
Median Weight Bead
There are N beads which of the same shape and size, but with different weights.
N is an odd number and the beads are labeled as 1, 2, ..., N. Your task is to
find the bead whose weight is median (the ((N+1)/2)th among all beads). The
following comparison has been performed on some pairs of beads:
A scale is given to compare the weights of beads. We can determine which one is
heavier than the other between two beads. As the result, we now know that some
beads are heavier than others. We are going to remove some beads which cannot
have the medium weight.
For example, the following results show which bead is heavier after M
comparisons where M=4 and N=5.
1. Bead 2 is heavier than Bead 1.
2. Bead 4 is heavier than Bead 3.
3. Bead 5 is heavier than Bead 1.
4. Bead 4 is heavier than Bead 2.
From the above results, though we cannot determine exactly which is the median
bead, we know that Bead 1 and Bead 4 can never have the median weight: Beads 2,
4, 5 are heavier than Bead 1, and Beads 1, 2, 3 are lighter than Bead 4.
Therefore, we can remove these two beads.
Write a program to count the number of beads which cannot have the median
weight.
Input (filename: F.IN)
The first line of the input file contains a single integer t (1 £ t £ 11), the
number of test cases, followed by the input data for each test case. The input
for each test case will be as follows:
The first line of input data contains an integer N (1=N=99) denoting the number
of beads, and M denoting the number of pairs of beads compared. In each of the
next M lines, two numbers are given where the first bead is heavier than the
second bead.
Output (Standard Output)
There should be one line per test case. Print the number of beads which can
never have the medium weight.
Sample Input Sample Output
1 2
5 4
2 1
4 3
5 1
4 2
Problem F -Page 1 of 2 </b></big></pre></code>
|
|
|
|
|
Did you read the guidelines before sending this query?
|
|
|
|
|
why in gods name do ppl like this think that we want to do their homework? i hate to sound racist but they all seem to come from one country...
|
|
|
|
|
Problem B
(Program filename: B.CPP, B.DPR, B.PAS or B.java)
Parallelogram Counting --
1. Join all the points with rest of the points( find all possible lines from the point set)
2. Group parallel lines.
3. Further group lines with same length among the parallel lines
4. Now very two lines will in the group make two edges of required parallelograms. If a group ha n lines then n*(n-1) will be total number number of edges in group.
5. Find total number of edges and divide them by 4.
Number is required number of parallegrams.
|
|
|
|
|
Concurrency is one of those things that gets me all worked up and interested, and part of the reason for this is because I find it great fun to be creating some sort of framework that others might be able to use, in order to increase their scalability, where all they have to do is figure out which parts are scalable, and leave the gory details of handling concurrency to the framework. Anyway, I'm looking to do some research and experimentation (and write a short document on my findings) on something concurrency related on Windows.
I've read some articles in the past on how to properly/efficiently use threadpools (by Herb Sutter, other concurrency gurus, and such), and one of the problems mentioned was a thread in a threadpool waiting on another thread in the threadpool, since you've effectively reduced your concurrency. I'd like to attempt to solve this problem in C++ by attempting a couple of techniques:
- Using fibers to emulate explicit wait API calls (WaitForSingleObject, etc.) so that waits essentially cause a switch to a different threadpool task, until the wait is ready.
The idea behind this is that we can preserve the number of threads in a threadpool, and have them switch between fibers while one is waiting on another thread, and then have them switch back to the original fiber when it's ready to run. This is because a thread can have multiple fibers. For those that don't know, a fiber can be sort of seen as a lightweight thread with its own stack space that is attached to an actual thread. Of course, feel free to correct me if I'm wrong, since I'm fairly new to this.
- Optimizing a threadpool by using more threads than can be efficiently used concurrently.
The idea behind this is that in a 4-core system, 4 active tasks can be performed at a time, but if one of these tasks waits on another task, then only 3 active tasks are working, so we optimize the threadpool by having for instance 6 tasks in all (4 running, 2 blocked), and when necessary to preserve maximum concurrency, we unblock the blocked tasks, and block them again where possible (I've seen allusions to the fact that we can do this, but this will require some more research).
I've already crafted (in previous attempts at research and testing), my own somewhat generic C++ threadpool framework, and my idea is to add the above concepts to what I currently have, to answer a few questions at least:
- Are my ideas feasible and not overly complicated?
- Is it possible to generalize what I'm trying to do in a framework?
- What are the scalability and performance benefits (or losses) that I can expect to see from implementing such functionality?
Any input or feedback into what I'm doing would be much appreciated. I'm not looking for existing code that already does what I want to do, but rather good lessons to be learned or things that I should know beforehand (things to avoid doing, traps, pitfalls, etc.), since I'm trying to learn myself, or at least, build on existing tools (though I doubt there's something I want to do that hasn't already been attempted). I estimate the scope of this project is something that I want to get done in 2 weeks worth of good work, coding and testing. I have a relatively good background in concurrency-related topics (my last two study projects were basic threadpooling and lockless synchronization techniques), but I'm still unsure if this is too much to take on at a time.
Sorry for the long post, and thanks in advance for reading!
|
|
|
|
|
Cyrilix wrote: - Using fibers to emulate explicit wait API calls (WaitForSingleObject, etc.) so that waits essentially cause a switch to a different threadpool task, until the wait is ready.
Requires you to emulate kernel waits (presuming you have more than one fiber per thread in the threadpool), or do you effectively poll the kernel objects on fiber context switches (oh, and you'll need to schedule them yourself somehow).
Cyrilix wrote: - Optimizing a threadpool by using more threads than can be efficiently used concurrently.
That sounds a lot simpler - maybe you can detect thread state and automatically add new threads to the pool as other threads enter wait states? And then reduce the number of active threads appropriately when the waits terminate?
Personally, my feelings about concurrency have been significantly influenced by the concurrency approaches of other programming[^] langauges[^]. Both those languages are functional, which avoids the problems of sharing data between threads. Erlang uses an actor model[^] of concurrency, while Haskell has several concurrency models. I think utilising the best approaches of those different models could offer significant improvements in achieving concurrency capable of making best use of multiple processing cores.
One other thought - for something a bit simpler, emulating the tasking model of Ada with C++ and threads might be an interesting challenge. Ada tasking has been knocking around since the early 1980s and is still (IMO and in many other people's opinions) a significantly better model of concurrent programming than basic threads.
Anyway - that may be of use, maybe not - I hope there's something coherent in there!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I don't exactly have a game plan for how I will handle fibers and waits so part of the task would be for me to see if the Windows API has any kind of built-in support for this. If I can somehow accomplish that, then I don't think the scheduling would be a problem because I can use a simple algorithm as proof-of-concept. As for the second idea, something like what you suggest will definitely be in the works. I'm actually a bit skeptical as to whether or not I'll see any major improvements here, but sometimes I surprise myself.
In terms of other languages and their concurrency approaches, that's probably something I'll want to look at if I have time, so I'll keep it in mind.
Thanks.
Edit: I gave some thought to what you said about the Ada task model vs. C++ and threads, and it seems to me like different concurrency models must still be implemented at the base with C++ or assembly. I guess the question then becomes, how do you use lower-level languages to implement a higher-level concurrency model. I think what I'm essentially trying to do here is to refine a higher-level task-based model by using something like threads.
modified on Sunday, July 12, 2009 8:23 PM
|
|
|
|
|
just wondering but does windows give u that type of control without writing a kernel mode driver type app? regarding fibre management etc. because i'm sure that windows has a system that deals with this so your going to be overriding it to a certain level.
or am i thinking about the wrong tangent?
|
|
|
|
|
I've never worked with fibers so I don't actually know. I see that they have a neat little API for some of the stuff that I might want to do, but that may not be sufficient. With respect to working with fibers, I'm starting from ground zero here.
I've also read a lot of articles warning very heavily against their usage, bugs, limitations, and etc. It's not too encouraging but still tempting, which is why I ask for some feedback.
|
|
|
|
|
ahh a fellow explorer not afraid of the dark or the unknown excellent, may i suggest running these apps on a spare PC...
i am having flash backs to when i started COM programming, my GUID registry entries would have won an award for coding horrors, and windows took about 35mins to boot up hahah the good ol days
|
|
|
|
|
#define R_GLDRAWELEMENTS 0x5ED02FD4
WINAPI _R_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
WINAPI (*R_glDrawElements)(GLenum , GLsizei , GLenum , const GLvoid *) = (void (__stdcall*) (unsigned int,int,unsigned int,void const *)) R_GLDRAWELEMENTS;
WINAPI _R_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
_R_glDrawElements( mode, count, type, indices);
}
The 3 line of code gives a bad error error C2059: syntax error : '('
And i dont know what is wrong with it the brackets seems to be all in place....
|
|
|
|
|
I'm not 100% sure how you didn't get other compiler errors, to be honest. I get errors where you've used WINAPI, as that doesn't (on my Windows installation) specify a return type - I have #define WINAPI __stdcall - just a calling convention.
Also - in the body of _R_glDrawElements, you call _R_glDrawElements recursively - that'll cause a stack overflow. Did you really mean R_glDrawElements??
Anyway - try this (modulo changing the body of _R_glDrawElements if I was correct above)
#define R_GLDRAWELEMENTS 0x5ED02FD4
void WINAPI _R_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void (WINAPI* R_glDrawElements)(GLenum , GLsizei , GLenum , const GLvoid *) = (void (__stdcall*) (unsigned int,int,unsigned int,void const *)) R_GLDRAWELEMENTS;
void WINAPI _R_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
_R_glDrawElements( mode, count, type, indices);
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|