Okay so i need really FAST algorithm or code in C if you have any it would be nice. The task is to sum all numbers from 1 to N for a given number N (it can be negative number too), so i did the usual way (you know just summing with loop from 1 to N) but it's not fast enough - i need something faster, i guess that i need the fastest possi...
Is there a way to initialize an array of primitives, say a integer array, to 0? Without using a for loop? Looking for concise code that doesn't involve a for loop.
:)
...
I'm trying to write an insert statement for a SQL Server table that inserts the value 1 into a decimal field. The field is of the type decimal(10, 10) which, as far as I understand, means that it can have up to 10 digits altogether, and up to 10 of those digits can be after the decimal point. But, when I try to run the insert statement I...
I am new to scala and I am finding the need to convert a boolean value to an integer. I know i can use something like if (x) 1 else 0 but I would like to know if there is a preferred method, or something built into the framework (ie toInt())
...
I am storing Integer objects representing an index of objects I want to track. Later in my code I want to check to see if a particular object's index corresponds to one of those Integers I stored earlier. I am doing this by creating an ArrayList and creating a new Integer from the index of a for loop:
ArrayList<Integer> courseselectItem...
hi.
does the following integer arithmetic property hold?
(m/n)/l == m/(n*l)
At first I thought I knew answer (does not hold), but now am not sure.
Does it hold for all numbers or only for certain conditions, i.e. n > l?
the question pertains to computer arithmetic, namely q = n/m, q*m != n, ignoring overflow.
...
I'll cut a really long story short and give an example of my problem.
Given a class that has a pointer to a primitive type as a property:
@interface ClassOne : NSObject
{
int* aNumber
}
@property int* aNumber;
The class is instantiated, and aNumber is allocated and assigned a value, accordingly:
ClassOne* bob = [[ClassOne alloc] in...
6.3.1.8p1: Otherwise, the integer promotions are
performed on both operands. Then the following rules are applied to the promoted operands: If both operands have the same
type, then no further conversion is needed. Otherwise, if both operands have signed integer types or both have unsigned integer
types, the operand with the typ...
Guys, I have a data structure which has 25 distinct keys (integer) and a value. I have a list of these objects (say 50000) and I intend to use a hash table to store/retrieve them. I am planning to take one of these approaches.
Create a integer hash from these 25 integer keys and store it on a hash table. (Yeah! I have some means to han...
I have been trying to solve this problem for a while, but couldn't with just integer arithmetic and bitwise operators. However, I think its possible and it should be fairly easy. What am I missing?
The problem: to get an integer value of arbitrary length (this is not relevant to the problem) with it's X least significant bits sets to 1 ...
ill have an if statement
if (int1 < int2)
{}
else
{}
I want the else statement to run if both int1 and int2 are 0..
...
I am writing a program that takes in an ArrayList and I need to calculate all possible permutations starting with a list of zeroes, up to the value in the corresponding input list.
Does anyone know how to iteratively calculate these values?
For example, given [ 1 2 ] as input, it should find and store the following lists:
[0 0],
[1 0]...
I have my repeater item template:
<asp:Repeater ID="Linksrepeater" runat="server">
<HeaderTemplate><h2>Links</h2><ul>
</HeaderTemplate>
<ItemTemplate>
<li><%#Container.DataItem("Category")%></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
Hooked up to:
s = "sql"
x = New SqlCommand(s, c)
...
hi,
I have the following values:
int a=1;
int b=0;
int c=2;
int d=2;
int e=1;
How do i concatenate these values so that i end up with a String that is 10221;
please note that multiplying a by 10000, b by 1000.....and e by 1 will not working since b=0 and therefore i will lose it when i add the values up.
Thnks you in advance.
...
Write a program which, given a list of up to 10 integer numbers and a sum, will display a subset of the numbers whose total is that sum if one exists or indicate that none exists otherwise. For example, for the list: 5,13,24,9,3,3 and sum = 28, your program should display 13, 9, 3, 3.
How to do this in C++ using a recursive function?
...
At work today, we threw together this attempt:
xquery version "1.0";
declare option saxon:output "omit-xml-declaration=yes";
declare variable $x := 99;
string-join(
for $b in (128,64,32,16,8,4,2,1)
let $xm := $x mod ($b*2)
return
if ( $xm >= $b ) then "1" else "0"
, "")
Do you have a better way?
Takin...
I defined a class:
class A:
''' hash test class
>>> a = A(9, 1196833379, 1, 1773396906)
>>> hash(a)
-340004569
This is weird, 12544897317L expected.
'''
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def __hash__(self):
return self.a ...
I have:
L1 = ['11', '10', '13', '12', '15', '14', '1', '3', '2', '5', '4', '7', '6', '9', '8']
this is a list of strings, right?
I need to make it a list of integers as follows:
L2 = [11, 10, 13, 12, 15, 14, 1, 3, 2, 5, 4, 7, 6, 9, 8]
finally I will sort it like below:
L3 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] by L2.sort()
please let ...
I have table in sql as
User | Account
-----+---------
1 | 25
1 | 31
1 | 35
1 | 44
1 | 50
1 | 59
and output need in as three columns
1 | 25 | 31
1 | 35 | 44
1 | 50 | 59
...
I'm not 100% on how to do this so i'm asking...
May seem stupid but...
How do I convert a string into an integer?
Background info:
I have a textbox I have the user enter a number into...
it then:
EditText et = (EditText) findViewById(R.id.entry1);
String hello = et.getText().toString();
gets the string 'hello'
Now I wan...