|
Not sure how this would work with a C++ DLL loaded into a C# application, but read what MSDN[^] says here, maybe it can get you going.
Registering/Using somekind of inbetween COM interface sounds like a good idea.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
hi all
here is the my code[quick_sort),plz point the errors,remove the errors plz
i want run this programme in fedora also[what exactly the header file would be to find time consumed for sorting a given array[sorted/unsorted] ]
#inlcude<stdio.h>
#include<conio.h>
#include<time.h>
Const int MAX=1000;
Int partition(int a[],low,int high)
{
Int I,j,,temp,key;
Key=a[low];
I=low;
J=high+1;
While(i<=j&& key<=a[i]);
{
i++;
}
While(key>a[j]);
{
j--;
}
If(i<j)
{
temp=a[i],a[i]=a[j],a[j]=temp;
}
Else
{
Temp=a[low],a[low]=a[j],a[j]=a[low;
Return j;
}
}
Void quick_sort(int a[],int low,int high)
{
Int mid;
If(low<high)
{
mid=partition(a,low,high);
quick_sort(a,low,mid-1);
quick_sort(a,mid+1,high);
}
}
Void main()
{
Int a[MAX],n,I;
Clock_t end,start;
Start=clock();
Printf("enter the no of elements:");
Scanf("%d",&n);
Printf("\n enter the elements to sort\n");
for(i=0;i<=n:i++);
scanf("%d",&a[i]);
quick_sort(a,0,n-1);
end=clock();
printf("\n the sorted elemetns are:\n\n"(;
for(i=0;i<=n:i++);
printf("%d\t",a[i]);
printf("\n\n time consumed the array is: %5.2f sec",(end-start)/CLK_TCK);
getch();
}
|
|
|
|
|
One thing I noticed is that u are starting the clock before providing the input so if u take 5 minutes to enter the elements it will also be counted as time-took-to-sort. so better move the start & end as below:
<br />
<br />
Start=clock(); <- remove from here<br />
Printf("enter the no of elements:");<br />
Scanf("%d",&n);<br />
Printf("\n enter the elements to sort\n");<br />
for(i=0;i<=n:i++);<br />
scanf("%d",&a[i]);<br />
Start=clock(); -> put it here<br />
quick_sort(a,0,n-1);<br />
end=clock();
now the algorithm running time is not including the time for printing the messages and taking user input.
|
|
|
|
|
One more thing, i have not done the statistical analysis though but u are using 2 while loops one nested inside other why not simlify it with one while loop, Here is my implementation for the same, hopefully it will help:
<br />
void swap(int a[], int i, int j)<br />
{<br />
int temp = a[i];<br />
a[i] = a[j];<br />
a[j] = temp;<br />
}<br />
<br />
void qsort(int *arr, int first, int last)<br />
{ <br />
int pivot;<br />
int left = first;<br />
int right = last;<br />
<br />
assert(arr != 0);<br />
if(left >= right)<br />
{<br />
return;<br />
}<br />
pivot = left++;<br />
while(left <= right)<br />
{<br />
if(arr[left] < arr[pivot])<br />
{<br />
swap(arr, left, pivot);<br />
pivot = left;<br />
++left;<br />
}<br />
if(arr[right] > arr[pivot])<br />
{<br />
swap(arr, right, pivot);<br />
pivot = right;<br />
--right;<br />
}<br />
}<br />
<br />
qsort(arr, first, pivot - 1);<br />
qsort(arr, pivot + 1, last);<br />
}<br />
|
|
|
|
|
hi Rahul
thanks for the reply
but your programme[modified used 1 while] doesnt give the time consumed to sort the given array
right?
|
|
|
|
|
Well I will then suggest the use of Boost's time duration class. I think there is one because i used to sometime back. check out the documentation of boost.
|
|
|
|
|
Beside moving the start=clock() call to a more appropriate place as previously suggested, an old trick I learned in order to have reproducible test timings, always start your timing run on the beginning of a fresh clock tick.
clock_t start, end, tt;
tt = clock();
while ((start = clock()) == tt);
...begin timing test
end = clock();
Don't start the timing until you get a different answer from clock(), now you have a whole clock tick to work with.
|
|
|
|
|
here is my code-but i am getting segmentation fault???? any body help me???
programme aim is:to find a time consumed[taken] for sorting a given array
#include<stdio.h>
#include<time.h>
const int MAX=1000;
int partition(int a[],int low,int high)
{
int i,j,temp,key;
key=a[low];
i=low;
j=high+1;
while(i<=j&&key<=a[i])
{
i++;
}
while(key>a[j])
{
j--;
}
if(i<j)
{
temp=a[i],a[i]=a[j],a[j]=temp;
}
else
{
temp=a[low],a[low]=a[j],a[j]=a[low];
return j ;
}
}
void quick_sort(int a[],int low,int high)
{
int mid;
if(low<high)
{
mid=partition(a,low,high);
quick_sort(a,low,mid-1);
quick_sort(a,mid+1,high);
}
}
void main()
{
int a[MAX],n,i,start,end;
double CLK_TCK;
printf("enter the no of elements:");
scanf("%d",&n);
printf("\n enter the elements to sort\n");
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
start=clock();
quick_sort(a,0,n-1);
end=clock();
printf("n the sorted elemetns are:\n\n");
for(i=0;i<=n;i++)
printf("%d\t",a[i]);
printf("\n\n time consumed the array is: %5.2f sec: ",(end-start)/(double)CLK_TCK);
}
|
|
|
|
|
You might get more help if you posted it to the Quick Answers instead of a reply just to me.
I can tell you that if you do post it in Quick Answers, the first thing people will ask for is "more information". Just saying "segmentatation fault" is not enough to go on. "Where" might help. ALso, nobody is just going to run and debug it for you, we don't have the data, the time, or the inclimation to do all the work for you. You'll have to show some results of your own debugging first.
|
|
|
|
|
I'm using SHFileOperation and it works well, but I really need to know when it's done because I'm setting the file permissions for users right after, and just want to make sure the files and folders are really there first.
I'm just looking for some suggestions on this if any may exist.
PS
I did write something for IFileOperation, but I was only able to get a single file copy to work, and haven't figured how to build the file array list for multiple folders and files.
|
|
|
|
|
Isn't it done when it returns?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
I thought that was the case, Wasn't really sure during some test runs, it looked like it was running in it's own thread.
I guess as long as the results are correct, that's all that matters.
|
|
|
|
|
It most likely does run in a separate thread but it also probably waits until this thread is done (just guessing this). However, if you experience that right after the operation some files can't be accessed it might be that the thread didn't release open handles yet to them (e.g. it is still in the process of terminating or somesuch) you could implement somekind of timeout mechanism, you try to access the file and keep trying periodically with some delays inbetween until you either succeed or some preset time period has passed, if you couldn't perform the operation before the time expired, error.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
That's a great idea, and I must concur with the theory. I'll write some extra code to test for file release first, and then proceed.
Thanks.
|
|
|
|
|
Hi,
I have implemented primitive voice removal by following the link:
http://www.cdf.utoronto.ca/~csc209h/summer/a2/a2.html[^]
It works, but not for all files and the results are not very consistent.
Any ideas and links to an open source libraries (C/C++/C#/Java) that do that, will be much appreciated.
Thanks,
Yuval
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
modified 15-Feb-12 12:05pm.
|
|
|
|
|
A good hard kick to the nadgers should keep them quiet for a while.
Software Zen: delete this;
|
|
|
|
|
OK, and how does this 'suggestion' help me with the problem?
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein
|
|
|
|
|
Sorry . When I posted my smart-ass reply, your message was in the Lounge. Good luck with your search.
Software Zen: delete this;
|
|
|
|
|
|
I want to let two client create TCP connection. These two clients are in different LAN, and there are firewalls, so these clients do not have WAN IP. But there is a server that these two client can visit.
Is there a way to create TCP connection between two clients through server?
|
|
|
|
|
TCP connections are based on the client-server concept. So two clients can not communicate even when in the same network segment.
It would be possible to create a special service that can pass through messages from one connected client to another one. But this requires a well-thought-out design of the protocol (identifying/addressing clients, keep-alive packets).
The usual way is to use port forwarding on the firewall / router to access servers behind. Other options are VLANs and tunneling.
|
|
|
|
|
Jochen Arndt wrote: TCP connections are based on the client-server concept. So two clients can not communicate even when in the same network segment.
Load of crap.
TCP is a non real time high quality protocol, it has sod all to do with clients and servers.
And can you open sockets between machines on the same sub net? Yes, you can. Regardless of which is a 'server'. (Define 'server'. Is it DHCP? Domain? File? How does the lack of installation of any number of 'server' components make a computer incapable of creating or accepting a socket connection?)
==============================
Nothing to say.
|
|
|
|
|
According to the subject the first part of my answer is about TCP connections, where a server listens on a socket and one or more clients can connect to the server.
The terms server and client are well defined in this context.
|
|
|
|
|
But you werent using client and server in that sense of a socket connection, you were using it in terms of network computers: "So two clients can not communicate even when in the same network segment."
==============================
Nothing to say.
|
|
|
|
|
Nit-pick.
A system that provides a service using a listening socket (or other methods) is a server. A system that connects to a server is a client. A system may be server and client at the same time.
|
|
|
|
|