is it possible to have a parameter like randP(j) such that ,5 element of randP select randomly then these elements fill with random-int , and other elements have value 0.
set j/1*50/;
parameter randP(j);
*select 5 elements (5 location j) randomly
*fill 5 locations by random integer value
*fill other locations by 0
Related
I have a file "a_test.dat" with two data blocks that I can select via the corresponding index.
# first
x1 y1
3 1
6 2
9 8
# second
x2 y2
4 5
8 2
2 7
Now I want to connect the data points of both indices with an arrow.
set arrow from (x1,y1) to (x2,y2).
I can plot both blocks with one plot statement. But I cannot get the points to set the arrows.
plot "a_test.dat" index "first" u 1:2, "" index "second" u 1:2
From version 5.2 you can use gnuplot arrays:
stats "a_test.dat" nooutput
array xx[STATS_records]
array yy[STATS_records]
# save all data into two arrays
i = 1
fnset(x,y) = (xx[i]=x, yy[i]=y, i=i+1)
# parse data ignoring output
set table $dummy
plot "" using (fnset($1,$2)) with table
unset table
# x2,y2 data starts at midpoint in array
numi = int((i-1)/2)
plot for [i=1:numi] $dummy using (xx[i]):(yy[i]):(xx[numi+i]-xx[i]):(yy[numi+i]-yy[i]) with vectors
Use stats to count the number of lines in the file, so that the array can
be large enough. Create an array xx and another yy to hold the data.
Use plot ... with table to read the file again, calling your function
fnset() for each data line with the x and y column values. The function
saves them at the current index i, which it increments. It was
initialised to 1.
For 3+3 data lines, i ends up at 7, so we set numi to (i-1)/2 i.e. 3.
Use plot for ... vectors to draw the arrows. Each arrow needs 4 data
items from the array. Note that the second x,y must be a relative delta,
not an absolute position.
You are given three integers n, a, and b. Determine if there exist two permutations p and q of length n, for which the following conditions hold:
The length of the longest common prefix of p and q is a.
The length of the longest common suffix of p and q is b.
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).
Input
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤104) — the number of test cases. The description of test cases follows.
The only line of each test case contains three integers n, a, and b (1≤a,b≤n≤100).
Output
For each test case, if such a pair of permutations exists, output "Yes"; otherwise, output "No". You can output each letter in any case (upper or lower).
Example
input
4
1 1 1
2 1 2
3 1 1
4 1 1
output
Yes
No
No
Yes
This is a random Codeforces' problem.
I don't understand the example, input and output.
Let suppose there is an array of cells each containing a specific set of valid characters.
Valid characters are either "Null/No value", "*", "X", "0", "1".
For simplicity sake, lets assume the array is 3 rows and 3 columns
Col1
Col2
Col 3
X
NV
0
*
1
X
1
NV
1
Glist = [[X,,0],[*,1,X],[1,,1]] /*assuming this is the right method to represent the 3X3 from above
How do I use count() function of array to determine how many times a certain value exists in the array elements?
I tried Glist.count(1) and it returned a value of 0
Thanks in advance.
If (temp = 8) Then
med = 0
Else
med = Application.Median(TP.Columns(j))
End If
Instead of using the in built function Application.Median, how do I calculate the median?
Instead of using in built functions you can create an array to store all your values and then get the median value by arranging the values and getting the one in array length/2.
If your array length / 2 is a decimal value you will have to get the values of rounding up and rounding down the array length/2, adding them and the dividing them by 2.
I'm creating a calculation table and want to align the numbers on the left under the '+'.
But somehow the first number in each column from the counter has some space before it.
How can I eliminate that space and align my table so that the left side is all in one row?
Code:
DATA: counter TYPE i,
counter2 TYPE i.
ULINE /(159).
WRITE: /1 sy-vline , '+', sy-vline.
DO 11 TIMES.
counter = sy-index - 1 .
WRITE: counter, sy-vline.
ENDDO.
ULINE /(159).
DO 11 TIMES.
counter = sy-index - 1 .
WRITE: /1 sy-vline , counter , sy-vline.
ULINE /(159).
ENDDO.
The spaces in front of the number are there because of the data type. Type i is an elementary data type and can have numbers from -2147483648 to 2147483647, which means it can be 11 characters long. Some data types have an output length that is variable, but that is not the case for i. You can see that if you click on it in your output, it should have a red outline 11 characters long.
But if you would rather have the spaces at the end of the number, then you can use 'CONVERSION_EXIT_ALPHA_OUTPUT'. But the "table outline" will still have to be just as big, since the number can have 11 characters.
DATA: counterc TYPE c LENGTH 11.
...
MOVE counter TO counterc.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = counterc
IMPORTING
output = counterc.
...
WRITE: ... counterc ...
Alternatively, the output of a table looks way better if you use SALV. Look here for example, to see how to output a table using SALV.