White spaces differ - input

Write a program that read integer user_num and div_num,and output user_num divided by div_num three times using floor division output is 1000 500 250
Print( int(user_num,end=‘ ‘)

Related

Pixel issue of characters in concatenation. Cols should be fixed as per the width for all the cols concatenated

These values are stored as part of 1 column. They are actually 3 cols concatenated through sql oracle. How can I make these values look aligned as 3 different cols?
Currently, these numbers will be 3 characters for 1 col, 10 for second and 7 for 3rd col. For some reason I had to bring them in 1 column to use in my rtf template. I need a solution in SQL Oracle to set width in concatenated cols. I am using cast here but this is the output I am getting
CAST(TO_CHAR(G_WEIGHTAGE)||'%' as char(3))||' '
||CAST(TO_CHAR(G_ACHIEVE , '990.00')||'%' as char(13)) ||' '
||CAST( TO_CHAR(ROUND((G_ACHIEVE_FACTOR*(G_WEIGHTAGE/100)),2)*(TARGET_BONUS/100), '990.00')||'%' as char(8)) AS G_WAIT
This is for 1st line in this output. I have written for other lines as well same way.
This is how it is coming
40% 96.79% 9.60%
10% 99.89% 2.70%
20% NA/ 51.42% 0.00%
10% 62.90% 0.00%
10% 112.77% 4.80%
Output I need :
40% 96.79% 9.60%
10% 99.89% 2.70%
20% NA/51.42% 0.00%
10% 62.90% 0.00%
10% 112.77% 4.80%
I believe this is due to different characters having different width. Like N has different width in comparison to 1.
Yeah, you want a PAD function. They add spaces to make a string a specific width. Try this:
lpad(TO_CHAR(G_WEIGHTAGE)||'%',3) ||' '
||lpad(TO_CHAR(G_ACHIEVE , '990.00')||'%',13) ||' '
||lpad(TO_CHAR(ROUND((G_ACHIEVE_FACTOR*(G_WEIGHTAGE/100)),9)*(TARGET_BONUS/100), '990.00')||'%',7) AS G_WAIT

Remove all but two trailing zeros AND thousand separator

Postgres Version 11.7
I am trying to remove trailing zeros beyond two decimal places, while also adding thousand separator to my result set.
Example 1 produces the desired result; all trailing zeros were removed:
SELECT to_char(54354.0010, 'FM99 999 999 990.999999'); --> returns 54 354.001
Example 2 illustrates the problem:
SELECT to_char(54354.0000, 'FM99 999 999 990.999999'); --> returns 54 354.
In Example 2 all zeroes after the decimal are removed.
But the desired result would be:
54 354.00
The result should always have a minimum of two decimal places, regardless whether they are zero or not.
This produces your desired result:
SELECT to_char(54354.0000, 'FM99 999 999 990.009999')
Two 0 instead of 9 after the decimal point.
The manual:
9 digit position (can be dropped if insignificant)
0 digit position (will not be dropped, even if insignificant)

How to handle decimal numbers in solidity?

How to handle decimal numbers in solidity?
If you want to find the percentage of some amount and do some calculation on that number, how to do that?
Suppose I perform : 15 % of 45 and need to divide that value with 7 how to get the answer.
Please help. I have done research, but getting answer like it is not possible to do that calculation. Please help.
You have a few options. To just multiply by a percentage (but truncate to an integer result), 45 * 15 / 100 = 6 works well. (45 * 15%)
If you want to keep some more digits around, you can just scale everything up by, e.g., some exponent of 10. 4500 * 15 / 100 = 675 (i.e. 6.75 * 100).

Circle Summation (30 Points) InterviewStree Puzzle

The following is the problem from Interviewstreet I am not getting any help from their site, so asking a question here. I am not interested in an algorithm/solution, but I did not understand the solution given by them as an example for their second input. Can anybody please help me to understand the second Input and Output as specified in the problem statement.
Circle Summation (30 Points)
There are N children sitting along a circle, numbered 1,2,...,N clockwise. The ith child has a piece of paper with number ai written on it. They play the following game:
In the first round, the child numbered x adds to his number the sum of the numbers of his neighbors.
In the second round, the child next in clockwise order adds to his number the sum of the numbers of his neighbors, and so on.
The game ends after M rounds have been played.
Input:
The first line contains T, the number of test cases. T cases follow. The first line for a test case contains two space seperated integers N and M. The next line contains N integers, the ith number being ai.
Output:
For each test case, output N lines each having N integers. The jth integer on the ith line contains the number that the jth child ends up with if the game starts with child i playing the first round. Output a blank line after each test case except the last one. Since the numbers can be really huge, output them modulo 1000000007.
Constraints:
1 <= T <= 15
3 <= N <= 50
1 <= M <= 10^9
1 <= ai <= 10^9
Sample Input:
2
5 1
10 20 30 40 50
3 4
1 2 1
Sample Output:
80 20 30 40 50
10 60 30 40 50
10 20 90 40 50
10 20 30 120 50
10 20 30 40 100
23 7 12
11 21 6
7 13 24
Here is an explanation of the second test case. I will use a notation (a, b, c) meaning that child one has number a, child two has number b and child three has number c. In the beginning, the position is always (1,2,1).
If the first child is the first to sum its neighbours, the table goes through the following situations (I will put an asterisk in front of the child that just added its two neighbouring numbers):
(1,2,1)->(*4,2,1)->(4,*7,1)->(4,7,*12)->(*23,7,12)
If the second child is the first to move:
(1,2,1)->(1,*4,1)->(1,4,*6)->(*11,4,6)->(11,*21,6)
And last if the third child is first to move:
(1,2,1)->(1,2,*4)->(*7,2,4)->(7,*13,4)->(7,13,*24)
And as you notice the output to the second case are exactly the three triples computed that way.
Hope that helps.

how to convert integer [70] in to [.70]?

How to convert a whole number into decimal..For example 70 to .70
because there are some price in my system that needed to be calculated by grams
for example $5 per grams...
I am saving the price in my database as an integer..
Thank's for dropping by
I didn't use vb for a long time, but, I guess, simple float division will work
Dim number As Integer
Dim result As Decimal
number = 70
result = number / 100.0
As you are storing cents and you want to display dollars divide the cents from the database by 100 and show that number in the user interface.
If the user enters an amount of dollars (and cents) multiply by 100 before storing in the database.