Questions tagged [operations]

298 questions
-2
votes
1 answer

Change text (if has a, double this letter) in Java

I have problem with this task: User will type some text. If text has 'a' triple this letter. If text has simply 'd' delete this letter. If text has double 'b' write only one 'b'. I understand this outlines but I do not know how to do it. How…
Tomas
  • 11
  • 1
-2
votes
3 answers

c++ sparse vector

Question 1) I have a large sparse vector of doubles in c++, I need to efficiently parse out the indices of the non zero elements from the vector. I can obviously loop over the length and do it, any better way to do it?
ganesh reddy
  • 1,842
  • 7
  • 23
  • 38
-3
votes
1 answer

check if n numbers are all odd or even using - + * operations only

is there a way to check N numbers if they are all odd or even without using mod function %??? ,i can only use - + * functions.
reeena11
  • 95
  • 1
  • 11
-3
votes
4 answers

python dictionary string operations

Currently I have my data in a directory myDict = {'a':'Andy','b':'Bill','c':'Carly' } I want to achieve something like input = a --> output = Andy input = ab --> output = Andy Bill input = abc --> output = Andy Bill Carly How can I do that ?…
DAA
  • 1
  • 2
-3
votes
2 answers

When I try to multiply an integer by a dictionary value (also an integer), it gives an answer that makes no sense

When I run the program and put in the values 3, 1, 1 so convert one cup to tablespoons, it uses the TOtbsp function at the bottom. For troubleshooting purposes, I've made it print out four variables before the final result. These variables all print…
-3
votes
2 answers

C++ operation too confusing?

I can't seem to understand this operation. What is the output of the following code? I've tried interpreting why b has two different values one as b=1+2 and the other as b=2, since a++ should equal to a=1+a ,then the cout is asking for ++b, which…
user665997
  • 313
  • 1
  • 4
  • 18
-3
votes
1 answer

Reset arraylist object property for all objects

I'm having an arraylist which contains object of class X. Class x has property name & desc. When I pass this object to a method, it needs to set all class object(X) description as 'MyDescription'. What is the best way to do it. For eg class X{ …
MukeshKoshyM
  • 514
  • 1
  • 8
  • 16
-3
votes
3 answers

How can I list all the combinations that meet certain criteria using Excel VBA?

Which are the combinations that the sum of each digit is equal to 8 or less, from 1 to 88,888,888? For example, 70000001 = 7+0+0+0+0+0+0+1 = 8 Should be on the list 00000021 = 0+0+0+0+0+0+2+1 = 3 Should be on the list. 20005002 = 2+0+0+0+5+0+0+2 =…
-4
votes
1 answer

Javascript division

In my console browser, I put: 666.66/10 And I get: 66.666 (As expected). But when I put: 6666.66/10 I get: 666.6659999999999 Can someone explain me why this happen? It shouldn't be: 666.666 ?
amp
  • 11,754
  • 18
  • 77
  • 133
-4
votes
5 answers

using operators ++ and -- in java, confused

I am very new to Java (4 weeks, 4 days a week), with zero prior programming knowledge. Can someone explain how this prints 32? int a = 10; a = a++ + a + a-- - a-- + ++a; System.out.println(a);
-6
votes
1 answer

operations with javascript in html document

I want the label with id="risultato" display the area of triangle,I tried to make this,but when I pressed button "risultato:" the risult is NaN,why? Thanks lots code: https://i.stack.imgur.com/52Pbd.png
Giuseppe Romeo
  • 111
  • 1
  • 2
  • 13
-6
votes
4 answers

Java loop - how many simple operations?

How many simple operations are performed in a simple java loop? int result = 0; for (int i = 0; i <= n; i++) { result = result + i; } We discussed in class and agreed on somewhat 8n+13 simple operations, but it would be nice with a correct,…
cascho
  • 1
  • 1
-6
votes
2 answers

How to minus from several MySQL fields a certain value

I am writing products stock script. I have a MySQL table "products_stock": id zid pid amount 1 123 321 1 2 124 321 5 4 124 566 7 3 125 321 10 So, total amount of product id = 321 in stock is 16. Somebody makes order…
Kamnibula
  • 88
  • 7
1 2 3
19
20