Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
TAChart component without x, y sort.
Ridiculous component behavior in lazarus TAChart where you can't determine an item in a chart without x,y sorting. I searched the demos and couldn't find anything about it.
Always x, y is sorted and I don't need it. Does anyone know how to change this...
Statistics is not just an increasing sequence, either by data or by date.
I don't know what you are doing. TListChartSource, to which you add values when you call AddXY, is NOT sorted by default.
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
x, y: Double;
begin
//Chart1Lineseries1.ListSource.Sorted := true;
for i := 1 to 30 do
begin
x := random;
y := random;
Chart1LineSeries1.AddXY(x, y);
end;
end;
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
program test (input,output);
var
a:array[1..5, 1..8] of integer;
n,max,i,j:integer
begin
writeln('enter massive 5*8');
for i:=1 to 5 do
for j:=1 to 8 do
readln(a[i,j]);
Find the largest absolute value of negative elements for each row of the matrix A (5,8) and rearrange them to first column.
Don't know what is the next step!What is my next step in this code?Please, help me)
Hint: you could to declare your matrix in a bit different way:
type
TMatrixRow = array[1..8] of Iteger;
TMatrix = array[1..5] of TMatrixRow;
var
a: TMatrix;
Then create procedure that rearranges row's values as you need:
procedure RearrangeRow(var r: TMatrixRow);
begin
// Your code here
end;
Finally call this procedure for each row:
for i := 1 to 5 do
RearrangeRow(a[i]);
Note that you still able to access matrix elements in usual way like a[row, column]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm wondering if anyone can propose an alternate way to write this code that avoids looping? Thanks!
for j=1:Ncol-1
for i=nr:Nitr
mydataD(k,1) = j;
mydataD(k,2) = i;
mydataD(k,3) = D(j,i);
k=k+1;
end
nr=nr+1;
end
[w,T] = kruskal(mydataD);
[r,c]=find(tril(D.',-1));
mydataD=[c,r,D(sub2ind(size(D),c,r))];
The transpose and swapped row/column are so that the row numbers are sorted. This doesn't include elements whose values are zero. If you actually want the zero values we'll have to change the first line:
[r,c]=find(tril(ones(size(D),-1));
mydataD=[c,r,D(sub2ind(size(D),c,r))];
This looks to me to be an attempted replacement for sparse matrices, changing from an adjacency matrix to an adjacency list. The equivalent sparse matrix would be:
mydataD=sparse(triu(D,1));
To avoid the loop you could do something like this:
mydataD = zeros(Ncol -1, 3);
i = linspace(1, Ncol -1, Ncol -1);
j = linspace(nr,Niter, Ncol -1);
mydataD(:,1) = i;
mydataD(:,2) = j;
mydataD(:,3) = D(j,i);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to have this loop but it says its not possible. How can I create these kinds of loops?
for i in range (sposA,sposB) and for j in range(eposB+1,sposB,-1):
if tempstr[i] == ctempstr[j]:
pcount += 1
In basically any language, such a construct would be ambiguous. Are you trying to loop in two dimensions (if each index list is x and y long, are you doing x*y things total?) or in parallel (are the indices the same length, e.g. x, and paired, so you only do x things?).
If you want to loop in two dimensions, you simply nest loops:
for i in range(x):
for j in range(y):
doStuff(i, j)
If they're parallel, you can either create some functional dependence between them so you can convert index i into index j, or combine the indicies:
for i in range(x):
j = f(i)
doStuff(i, j)
or
for i, j in zip(range(x), range(y)):
doStuff(i, j)
The above stuff is in Python-pseudocode, but the control structures are broadly applicable in any imperative language (C, Python, Java...).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
could you please help me with my homework? I am just a beginner and know very little about Pascal :(
I am supposed to write a program for division but have special conditions depending on their decimal numbers. The outputs should look something like this:
no decimals then 20/5=4 (there can only be the 4; it can't be like 4.00)
if decimals then only 1 decimal number 9/4=2.3
if the decimal is an infinite of the same number then 1/3=0.(3)
How can I do it? I was thinking about putting it into an array but I don't know how to find where the decimal point is nor I know how to write the brackets into an output.
I can't manage to solve the 3rd point but here is the code for the first 2:
Var
x,y : integer;
z : real;
Begin
z := x / y;
if z = x div y
then Write(z:4:0) //Write a real var without any decimals
else Write(z:4:1); //Write a real var with just 1 decimal
End.
You'll have to change things around , like reading x and y , but from this code you can almost do your homework .
I'll try to solve the 3rd time , check the answer again after some time.
To solve 3rd point: think about x and y as about a fraction. Here is the basic idea:
A:=A/GCD(A,B);B:=B/GCD(A,B)
Integer part := A div B; A:=A mod B
Non-periodical part: while A mod 2=0 do BEGIN C:=C*2;A:=A div 2; END; while A mod 5=0 do BEGIN C:=C*5;A:=A div 5; END
Find M so that A*M=999..999.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
i am wondering if it is possible to simplify:
T*V + V*T // V = V^(t) symmetric
where both operands are matrixes
I don't think this is possible due to the following considerations:
If we multiply two matrices A and T, where A is symmetric (i.e. A(i,j) = A(j,i)), we have the following:
For A*T we have that the item in row z and column s is computed as:
__n__
\
/ A(z,i)*T(i,s)
-----
i=1
For the other way around, T*A, we get for row z, column s:
__n__ __n__
\ \
/ T(z,i)*A(i,s) = / T(z,i)*A(s,i)
----- -----
i=1 i=1
So, as long as we do not know anything about the entries T(i,j) in T, I think we can not say how these sums relate to each other.