|
ok i showed my @#$ contribution
|
|
|
|
|
Gimme a few more mins ... working on a recursion solution.
Jedi
|
|
|
|
|
cheers, still busy myself
|
|
|
|
|
using System;
namespace ConsoleApplication2
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
Calculate c = new Calculate();
c.initCalc();
System.Console.WriteLine ("Done");
System.Console.Read ();
}
}
public class Calculate
{
int[] intArray = {1,2,3,4,5,6,7,8,9};
public void initCalc()
{
string s_out = "";
int iTotal = 0;
int j=0;
for(int i = 0; i < intArray.Length; i++)
{
iTotal = intArray[i];
s_out = intArray[i].ToString() + " + ";
j=i;
calc(intArray, j, s_out, iTotal);
}
}
public string calc(int[] intArray, int j, string s_out, int iTotal)
{
String s_out2;
if(iTotal == 10)
{
s_out = s_out.Substring(0,s_out.LastIndexOf("+")-1) + " = " + iTotal.ToString();
Console.WriteLine(s_out);
}
while(iTotal < 10 && j<intarray.length)
{
="" itotal="iTotal" +="" intarray[j];
="" s_out2="s_out;
" s_out="s_out" intarray[j].tostring()="" "="" ";
="" calc(intarray,j,s_out,="" itotal);
="" -="" j++;
="" }
="" if(itotal="">10)
{
s_out = "";
}
return s_out;
}
}
}
Jedi
|
|
|
|
|
cheers jedi,
i can see 42 out of 98 possiblities...
you've helped me a lot, cheers
|
|
|
|
|
The program i wrote should give you all distinct possibilities ... what do you mean 42 out of 98?
|
|
|
|
|
you're right, these guys are mistaken by 98...
i've checked and it's absolutely correct.
Thank you
|
|
|
|
|
If it's not a class assignment, you should have made that clear from the beginning. It looks very much lika a class assignment.
I would solve it recursively. Make a method that creates all combinations to get the sum "n" by looping a number and use itself to get all combinations to fill the difference between the number and "n".
---
b { font-weight: normal; }
|
|
|
|
|
class Program
{
static void Main(string[] args)
{
Program pg = new Program();
pg.allTenSum();
Console.ReadLine();
}
public void allTenSum()
{
int check = 0;
string add = "";
int[] a ={ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
List<string> val = new List<string>();
foreach (int abc in a)
{
for (int m = abc; m < 10; m++)
{
if ((m + abc) <= 10)
{
add = Display(abc, m);
foreach (string disp in val)
{
if (disp == add)
check = 1;
}
if (check != 1)
{
if (add != "")
val.Add(add);
}
}
}
}
foreach (string disp in val)
{
Console.WriteLine(disp);
}
}
public string Display(int a, int b)
{
int testTen = 0;
string str = "";
str = str + b + "+" + a;
testTen = testTen + a + b;
while ((testTen + a) < 10)
{
if (str == "")
{
str = str + a;
}
else
{
str = str + "+" + a;
}
testTen = testTen + a;
}
if ((10 - testTen) != 0)
{
int k = 10 - testTen;
str = str + "+" + k;
}
return str;
}
}
Output is :
1+1+1+1+1+1+1+1+1+1
2+1+1+1+1+1+1+1+1
3+1+1+1+1+1+1+1
4+1+1+1+1+1+1
5+1+1+1+1+1
6+1+1+1+1
7+1+1+1
8+1+1
9+1
2+2+2+2+2
3+2+2+2+1
4+2+2+2
5+2+2+1
6+2+2
7+2+1
8+2
3+3+3+1
4+3+3
5+3+2
6+3+1
7+3
4+4+2
5+4+1
6+4
5+5
|
|
|
|
|
hi all,
i want to create a windows form where-in i want to get the list all web methods found within a webservice, in a list box, by giving the url of the .asmx file as input. iv got slight idea that i need to use the "System.Web.Services.Discovery" and "System.Web.Services.Description" namespaces for this....
but have no idea as to how to proceed further and get my requirement completed!!!!
If any one could help me with a piece of sample code it would be of great use!!!
Thanks in advance!!1
regards
Compdesign..
|
|
|
|
|
|
I am working on a windows application .This application will be running in the background and capturing all the keystrokes .All the short-cut keys need to be disabled i.e. Alt+F4 or windows+M etc by this application.If the user presses alt+ctrl+8 he should be shown a login screen and if he is authorised the keys should be enabled according to his permission level i.e Admin ,user etc. If this application has got the focus then only it captures events , but as the case mostly is ,there is some other application running which will have focus but I still want to get these keystroke events in my application .Any help please.
Thank you.
|
|
|
|
|
That sounds like either a) a virus or b) some other form of malware you are writing there.
If im wrong, then please feel free to explain a legit reason to have this functionality! Until then I hope nobody gives you any advice.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I am neither creating a virus nor any malware . I am working in a company whose product is kiosk .For its security purpose I need to implement this functunality so please help .
|
|
|
|
|
Kiosks dont use traditional keyboards, so why would you need to deactivate keyboard input?
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
For some reasons my company is using traditional keyboards with all the keys.
|
|
|
|
|
Well, you wil finds solution anything what it needs for.
Watch this code project article: Low-level Windows API hooks from C# to stop unwanted keystrokes
[^]
Goodluck with virus or whatevar. Worry is not needed Im sure, to be infected at my pc. I use McAfee.
Be sure to use .Net 1.1... or your virus won't run on as many Windows installations...
|
|
|
|
|
I am unaware of the users intentions, however there can be legit reasons for wanting to do so.
For example, an internet cafe owner may wish to disallow the paying customer from doing anythign else other than IE.
A school's public computer might want to restrict the 'children' from installing stuff and/or fiddling around with the windows registry.
An internet kiosk (like the one at airports ... and they usually have normal keyboards embedded in metal) where public can't be trusted enough from installing stuff and/or gaining access rights on the Pc ...
etc ...
Use your imagination ...
Jedi
|
|
|
|
|
nueer wrote: Goodluck with virus or whatevar. Worry is not needed Im sure, to be infected at my pc. I use McAfee.
Maybe. I've recently written a keyboard/mouse hook app and Symantec AV didn't bat an eye at it.
|
|
|
|
|
Yes... But why in heaven's name would one create a virus that runs on the .Net framework?
I'm very naive when it comes to viruses and such, possibly because I've never been seriously affected by one... Does it ever make sense to write your virus using C# .Net? Unless it exploits the .Net Framework specifically...
Sorry, thats off-topic. Hooking key-strokes is a handy little thingy. Can't see why someone would immediately assume it's a virus.
Sorry for my poor grammar... boredom at work... it's a curse and a blessing.
|
|
|
|
|
nueer wrote: Sorry, thats off-topic. Hooking key-strokes is a handy little thingy. Can't see why someone would immediately assume it's a virus.
Mainly I think it's a case of better safe than sorry. On anything viruslike the working rule here seems to be guilty until proven innocent. A legit sounding reason for wanting something is treated as proof of innocence, when combined and the assumption that a kidiot won't be able to come up with a legit sounding reason if cornered. I'm not sure it's the best solution but can't think of anything better myself.
|
|
|
|
|
I have one Web application where I have used window basic authentication, so every time when user access application popup window will come for userid/password.
Till now there is no problem. Now within same application I have some new page which needs no authentication means Anonymous user can access.
i do not want to use 'Anonymous Access'.
is it possible we can pass authentication credential by page .
Plz advice me what code I have to write in new page so any one can access these page
Raghvendra Raghuwanshi
|
|
|
|
|
I have the following C function declaration
void Test(INT16 hA, UINT8* pB, UINT8 pTagType[4], UINT8 pC[4], UINT8 pD[4][10]);
I read in an article that I need to use MarshalAs. The problem is i don't know how to do it, especially with 2D array.
Thanks in Advance,
Tony
|
|
|
|
|
Hi,
I am having problems writing a com interface in c#. The problem I am having is to do with mapping properties on the com interface to the c# interface.
For example if I have the following IDL for a com interface.
[
uuid(56a868b4-0ad4-11ce-b03a-0020af0ba770),
helpstring("IVideoWindow interface"),
odl,
oleautomation,
dual
]
interface IVideoWindow : IDispatch
{
// properties
...
[propput]
HRESULT Height([in] long Height);
[propget]
HRESULT Height([out, retval] long *pHeight);
...
}
and run tlbimp I get a c# interface that has the following meta data. That is it has get and set accessors.
[TypeLibType(4160)]
[Guid("56A868B4-0AD4-11CE-B03A-0020AF0BA770")]
public interface IVideoWindow
{
...
[DispId(1610743828)]
int Height { get; set; }
...
}
This works perfectly!
but If I want to bypass all the IDL approach and have a pure C# solution the only way I can get correct access to the com interface is to write it as follows. That is with get_ and put_ methods.
[Guid("56a868b4-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IVideoWindow
{
...
[PreserveSig]
int put_Height([In] int height);
[PreserveSig]
int get_Height([Out] out int height);
...
}
Although this works I would prefer to write with get and set accessors.
The question is short is how do I rewrite a com interface in c# that using get and set and not put_XXXX and get_XXXX so as I can write code as follows.
vidWin.Height = 87;
and not
vidWin.put_Height(87);
btw using the meta data from the IDL approach does not work!
Thanks in advance for any help.
pdm
|
|
|
|
|
Hi,
I have created a class object and populated it with the data. Now i want to export the data into a XML format. Is there any direct way of exporting the object data to XML? if yes, can you provide me with the code snippet??
Thanks in advance for any suggestions and help
Regards,
Kais
|
|
|
|