Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Loops-Nested/R/loops-nested-1.r
Normal file
22
Task/Loops-Nested/R/loops-nested-1.r
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
m <- 10
|
||||
n <- 10
|
||||
mat <- matrix(sample(1:20L, m*n, replace=TRUE), nrow=m); mat
|
||||
done <- FALSE
|
||||
for(i in seq_len(m))
|
||||
{
|
||||
for(j in seq_len(n))
|
||||
{
|
||||
cat(mat[i,j])
|
||||
if(mat[i,j] == 20)
|
||||
{
|
||||
done <- TRUE
|
||||
break
|
||||
}
|
||||
cat(", ")
|
||||
}
|
||||
if(done)
|
||||
{
|
||||
cat("\n")
|
||||
break
|
||||
}
|
||||
}
|
||||
5
Task/Loops-Nested/R/loops-nested-2.r
Normal file
5
Task/Loops-Nested/R/loops-nested-2.r
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
m <- 10; n <- 10; mat <- matrix(sample(1:20L, m*n, replace=TRUE), nrow=m);
|
||||
x<-which(mat==20,arr.ind=TRUE,useNames=FALSE)
|
||||
x<-x[order(x[,1]),]
|
||||
for(i in mat[1:x[1,1]-1,]) print(i)
|
||||
for(i in mat[x[1,1],1:x[1,2]]) print(i)
|
||||
Loading…
Add table
Add a link
Reference in a new issue