Zobraziť témy bez odpovede | Zobraziť aktívne témy Aktuálny čas je 24 Feb 2020, 5:16



Odpovedať na tému  [ Príspevkov: 10 ] 
Ciferný súčet čísla v C
Hľadať:
Facebook Twitter Vybrali Sme  
 
Autor Správa
Amateur
Amateur
Obrázok užívateľa

Registrovaný: 25.9.2014
Príspevky: 34
Karma: Neutrál
Príspevok Ciferný súčet čísla v C
Čaute, riešim program na ciferný súčet čísla, no mám s tým menší problém. Na výstupe musí byť jedna číslica, tzn. keď na vstupe dostanem 165, na výstupe musí byť 3 (1+2), nie 12. Môj program mi zatiaľ hádže iba 12, neviem ako ten cyklus zopakovať, viete mi s tým niekto pomôcť? Dík :)


09 Apr 2018, 22:15
Profil  
Amateur
Amateur
Obrázok užívateľa

Registrovaný: 6.3.2018
Príspevky: 10
Karma: Neutrál
Príspevok Re: Ciferný súčet čísla v C
Ahoj, rad by som ti pomohol, ale nejak nechapem, ako ten vystup vlastne ma vyzerat. Nejak mi to 1+2 vobec nedava zmysel.


09 Apr 2018, 22:27
Profil  
Expert
Expert
Obrázok užívateľa

Registrovaný: 12.6.2014
Príspevky: 161
Karma: Neutrál
Príspevok Re: Ciferný súčet čísla v C
do danej funkci das na koniec:

if(x.lenght > 1)
return funkcia(x);
else
return x;

Ccko som uz zabudol no logika by snad mala fungovat. Ide o to ze ak ziskas cislo ktore ma viac ako 2 cifry tak danu funkciu volas znova.
Snad som pomohol.

EDIT: Neviem akym sposobom pocitas sucet tych cisel. Teraz som si to skusal nakodit a +- to mam tak ako som napisal. Ak to ma po vypocitani viac ciset (>9), tak volam funkciu nanovo.. Zatial co som testoval moj kod, tak funguje v pohode.

Este taka poznamka, ak to mas do skoly, tak by si sa s tym mal potrapit sam...


09 Apr 2018, 22:29
Profil  
Addict
Addict
Obrázok užívateľa

Registrovaný: 27.5.2009
Príspevky: 3820
Bydlisko: Bratislava
Karma: Level +4
Príspevok Re: Ciferný súčet čísla v C
alvar píše:
Čaute, riešim program na ciferný súčet čísla, no mám s tým menší problém. Na výstupe musí byť jedna číslica, tzn. keď na vstupe dostanem 165, na výstupe musí byť 3 (1+2), nie 12. Môj program mi zatiaľ hádže iba 12, neviem ako ten cyklus zopakovať, viete mi s tým niekto pomôcť? Dík :)


Tkze mas funkciu, ktora robi ciferny sucet napriklad "int disgitsSum(int n)".

Teraz mas pravdepodobne program, ktory vyzera nejako takto:
Kód:
int n;
scanf("%i", &n);
int result = disgitsSum(n);
printf("Ciferny sucet je: %i\n", result);


tak ho prerobis na daco taketo:

Kód:
int n;
scanf("%i", &n);
int result = n;
while(result >10)
{
  result  = disgitsSum(result);
}

printf("Ciferny sucet je: %i\n", result);


//autoeditácia príspevku (10 Apr 2018, 7:40)
Keby ukazes kod, radi sa ti lahsie.


10 Apr 2018, 6:39
Profil  WWW
Amateur
Amateur
Obrázok užívateľa

Registrovaný: 25.9.2014
Príspevky: 34
Karma: Neutrál
Príspevok Re: Ciferný súčet čísla v C
x = 0
if(x > 0){
print("Kladn? ??slo.")
} else if(x < 0){
print("Z?porn? ??slo.")
} else {
print("Nula.")
}

#FOR
f = seq(1,100,by=2)
a = NULL
for(i in 1:50){
a[i] = f[i]^2
}
print(a)

#FOR, NEXT
for(i in 1:100){
if(i <= 50){
next
}
print(i)
}

#WHILE
count = 0
while(count < 10){
print(count)
count = count + 1
}

#REPEAT, BREAK
sum = 1
repeat{
sum = sum + 2
print(sum)
if(sum > 11)
break
}

#LAZY
f = function(a,b){
a^2
}
f(2)
f = function(x,y=2){
x^y
}

#ARGUMENT
args(paste)
paste("c", "a", "u")
paste("c", "a", "u", sep=":")

M = matrix(1:6,3,2)
M
apply(M,2,sum) #sucet stlpcov
apply(M,1,sum) #sucet riadkov
apply(M,1,mean) #stredn? hodnota
apply(M,2,mean)

#Vytvorenie adresara
setwd("C:\\Users\\Guest\\Desktop\\adr")
dir.create("C:\\Users\\Guest\\Desktop\\adr")
file.exists("C:\\Users\\Guest\\Desktop\\adr")

dir.create("data")

#ziskavanie dat z webu
fileUrl = "http://people.tuke.sk/peter.butka/res/irisdata.csv"
download.file(fileUrl, destfile = "data\\iris.csv")
list.files("data")

#nacitanie lok. text suborov
dfiris = read.table("data\\irisdata.csv", sep = ";", header = TRUE)
head(dfiris)

fileUrl = "http://people.tuke.sk/peter.butka/res/irisdata.xlsx"
download.file(fileUrl, destfile = "data\\irisdata.xlsx", mode = "wb")
library(xlsx)
data = read.xlsx("data\\irisdata.xlsx",sheetIndex=1,header=TRUE)
subdata = read.xlsx("data\\irisdata.xlsx",sheetIndex=1, colIndex=2:3,rowIndex=1:5)


#nacitavanie XML suboru
library(XML)
library(RCurl)
url = "https://www.w3schools.com/xml/simple.xml"
xData = getURL(url)
doc <- xmlTreeParse(xData)
root <- xmlRoot(doc)
xmlName(root)
root[[2]]
root[[2]][[1]]


xmlSApply(root,xmlValue)
xpathSApply(root,"//name",xmlValue)
xpathSApply(rootNode,"//price",xmlValue)

#JSON subory
library(jsonlite)
fileUrl = "http://people.tuke.sk/peter.butka/res/data.JSON"
download.file(fileUrl, destfile = "data\\data.JSON")
mydata = fromJSON("data\\data.JSON")
names(mydata)
mydata
names(mydata$adresa)
mydata$adresa$mesto

myjson = toJSON(iris, pretty=TRUE)
cat(myjson)
write(myjson, file="irisdata.JSON")

#Mysql
library(RMySQL)
library(DBI)
hg19 = dbConnect(MySQL(),user="genome", db="hg19", host="genomemysql.cse.ucsc.edu")
dbs = dbGetQuery(genDB,"show databases;");
dbDisconnect(genDB);
dbs

#Nacitanie z Web stranok
library(XML)
s = htmlParse("http://www.catholic-hierarchy.org/bishop/spope0.html")
tabs = readHTMLTable(s, stringsAsFactors=FALSE)
popes = tabs[[1]][2:6,c(2,3,5)]
names(popes) = c("meno","narodeny", "zvoleny")
popes

#Data.table
library(data.table)
dt = data.table(x=rnorm(5), y=rnorm(5), z=rnorm(5))
dt
tables()
dt[dt$z > 0,]
dt[3,]
dt[,w:=z^2]
dt[,y:={tmp = x+y; tmp^2}]
dt[,b:= sum(x),by=x]
dt[, .N, by=y]

X <- data.frame("var1"=sample(1:5),"var2"=sample(6:10),"var3"=sample(11:15))
X$var2[c(1,3)] = NA #PRIDAVANIE HODNOTY

X[,1] # výber všetkých riadkov a 1 stlpca
X[,"var1"] # výber všetkých riadkov a stlpca s názvom "var1"
X[1:2,"var2"] # výber 1 až 2 riadka a stlpca s názvom "var2"

X[(X$var1 <= 3 & X$var3 > 11),] # výber riadkov, ktoré splňajú dané podmienky a všetky stlpce (& - a zároveň)
X[(X$var1 <= 3 | X$var3 > 15),] # výber riadkov, ktoré splňajú jednu z daných podmienok a všetky slpce (| - alebo)

X[which(X$var2 > 8),] # výber riadkov kde var2 > 8, which - ignorovanie NA hodnôt

X$d = rnorm(5) # pridanie stlpca d
Y = cbind(X,rnorm(5)) # vytvorenie tabulky/matice Y s dátami X a novým slpcom

sort(X$var1) # usporiadanie premennej var1 zostupne(od najmenšieho po najväčšie)
X[order(X$var1),] # usporiadanie celého DF podľa premennej var1


############################ Vytvaranie novych premennych #######################
s1 = seq(1,10,by=2)
s1
s2 <- seq(1,10,length=3)
s2

X <- data.frame("var1"=sample(1:5),"var2"=sample(6:10),"var3"=sample(11:15))
X$c = ifelse(X$var1 > 0,TRUE,FALSE) # vytvorenie binárneho stlpca c
X$d = cut(X$var1,breaks = quantile(X$var1)) # vytvorenie kategorialnej premennej z numerického atribútu

install.packages("Hmisc")
library(Hmisc)
X$e = cut2(X$var1,g=4) # vytvorenie kategorickej premennej cez príkaz cut2

yesno <- sample(c("yes","no"),size=10,replace=TRUE) # vytvorenie vektora s dlžkou 10 z hodnôt yes,no
yesnofac = factor(yesno,levels=c("yes","no")) # vytvorenie faktora a zadanie levelov
relevel(yesnofac,ref="no") # zmena poradia levelov

install.packages("plyr")
library(Hmisc)
library(plyr)
X2 = mutate(X,novy = cut2(var1,g=4))

#################### Transformacia dat #####################################
abs(-5)
sqrt(9)
ceiling(4.45) # zaokrúhli stále nahor
floor(4.45) # zaokrúhli stále nadol
trunc(4.45) # zaokrúhli stále nadol
round(4.4586325,digits = 5)
signif(4.4586325,digits = 5)
round(3.475,digits = 2)
signif(3.475,digits = 2)
cos(0.754)
sin(0.754)
log(0.754)
log2(0.754)
log10(0.754)
exp(0.754)

substr("abcdef", 2, 4) # vytvorí podreťazec od 2 až po 4 znak
data <- data.frame(values=c(91, 92, 108, 104, 87, 91, 91, 97, 81, 98),
names = c("fee-", "fi", "fo-", "fum-", "foo-", "foo1234-", "123foo-","fum-", "fum-", "fum-"))
data$values[grep("foo",data$names)]

x <- c("This is a sentence about axis","A second pattern is also listed here")
sub("is", "XY", x)
gsub("is","XY",x)

x <- "Split the words in a sentence."
strsplit(x, "t")
strsplit(x, "l")
strsplit(x, " ")

paste(1,2,3,4,5,sep=".")
toupper("programovanie")
tolower("ABCD")

####################### Spajanie dat #################################
library(plyr)
df1 = data.frame(id=sample(1:10),x=rnorm(10))
df2 = data.frame(id=sample(1:10),y=rnorm(10))
arrange(join(df1,df2),id) # spojenie df1 a df2 pomocou knižnice plyr a stlpca id

df3 = data.frame(id=sample(1:10),z=rnorm(10))
dfList = list(df1,df2,df3) # vytvorenie listu z prvkov df1,df2,df3
join_all(dfList) # spojenie všetkych prvkov listu


merged1 = merge(df1,df2,by="id")
merged = merge(df1,df2,by.x="id",by.y="id")
intersect(names(df1),names(df2))
merged2 = merge(df1, df2,all=TRUE)

########################## Restruktalizacia dat #####################
mtcars$carname <- rownames(mtcars)
install.packages("reshape")
library(reshape)

# z dát mtcars vytvoríme stlpce id, ktoré budú mať hodnoty carname, gear a cyl a následne pre stlpce mpg a hp sa vytvoria hodnoty variable a value
carMelt <- melt(mtcars,id=c("carname","gear","cyl"),measure.vars=c("mpg","hp"))

head(carMelt,n=3)

# vstupom sú najprv dáta, na kt. bol aplikovaný melt, a nasleduje formula, ktorá určuje aké riadky a stlpce sa kombinujú
cylData <- cast(carMelt, cyl ~ variable)
cylData1 <- cast(carMelt, cyl ~ variable,mean)

##################### Regex #####################
grep("^a", c("abc", "def", "cba a", "aa"), value=FALSE)
grep("^a", c("abc", "def", "cba a", "aa"), value=TRUE)

################################Grafy######################################
download.file("http://people.tuke.sk/peter.butka/res/avgpm25.csv","avgpm25.csv")
pmdata = read.csv("avgpm25.csv", colClasses = c("numeric","character","factor", "numeric", "numeric"))
head(pmdata)
summary(pmdata$pm25)

####################### 1D grafy #########################################
boxplot (pmdata$pm25,col = "red")
barplot(table(pmdata$region), col= "red", main = "Number of Counties in Each Region")
hist(pmdata$pm25, col="blue", breaks=150)
rug(pmdata$pm25)
abline(v = 12, lwd = 4, col="magenta")
abline(v = median(pmdata$pm25), col = "yellow", lwd = 4)

####################### 2D grafy ##########################################
boxplot(pm25 ~ region,data = pmdata, col ="red")
par(mfrow = c(2, 1), mar = c(4, 4, 2, 1))
hist(subset(pmdata, region == "east")$pm25,col = "green")
hist(subset(pmdata, region == "west")$pm25,col = "green")

with(pmdata, plot(latitude,pm25))
abline(h = 1, lwd = 1,lty = 1)
with(pmdata, plot(latitude, pm25,col = region))
abline(h = 12, lwd = 2, lty = 2)
legend(x="topright", legend =levels(pmdata$region),col=c("red","black"), pch=1)
par(mfrow = c(1, 2), mar = c(5, 4, 2, 1))
with(subset(pmdata, region == "west"), plot(latitude, pm25,main = "West"))
with(subset(pmdata, region == "east"), plot(latitude, pm25,main = "East"))

##################### System vykreslovania #############################
library(datasets)
data(cars)
with(cars, plot(speed, dist))

library(lattice)
state = data.frame(state.x77,region = state.region)
xyplot(Life.Exp ~ Income | region, data = state, layout = c(4, 1))

library(ggplot2)
data(mpg)
qplot(displ, hwy, data = mpg)
pdf(file = "myplot.pdf"); plot(x,y); dev.off()

##################### Base ####################################
with(airquality, plot(Wind, Ozone, main = "Ozone and Wind in New York City ", type = "n"))
with(subset(airquality, Month == 5), points(Wind, Ozone, col = "blue"))
with(subset(airquality, Month != 5), points(Wind, Ozone, col = "red"))
legend("topright", pch = 1, col = c("blue", "red"), legend = c("May", "Other Months"))
model = lm(Ozone ~ Wind, airquality)
abline(model, lwd = 2)

par(mfrow = c(3, 1), mar = c(4, 4, 2, 1), oma = c(0, 0, 2, 0))
with(airquality, {
plot(Wind, Ozone, main = "Ozone and Wind")
plot(Solar.R, Ozone, main = "Ozone and Solar Radiation")
plot(Temp, Ozone, main = "Ozone and Temperature")
mtext("Ozone and Weather in New York City", outer = TRUE)
})

#################### Lattice funkcie ##################
library(datasets)
library(lattice)
airqt = transform(airquality, Month = factor(Month))
xyplot(Ozone ~ Wind | Month, data = airqt, layout = c(5, 1))

set.seed(10)
x = rnorm(100); f = rep(0:1, each = 50)
y <- x + f - f * x + rnorm(100, sd = 0.5)
f <- factor(f, labels = c("Group 1", "Group 2"))
xyplot(y ~ x | f)
xyplot(y ~ x | f, layout = c(1, 2))

xyplot(y ~ x | f, panel = function(x, y, ...) {
panel.xyplot(x, y, ...) # volanie default panel funkcie
panel.abline(h = median(y), lty = 2)
# rridanie horizontálnej čiary pre medián
panel.lmline(x, y, col = 2) # pridanie regresnej priamky
})

################## gplot ###################################
qplot(displ, hwy, data = mpg)
qplot(displ, hwy, data = mpg, col=drv)
qplot(displ, hwy, data = mpg, geom = c("point", "smooth"))





# ------------------------------------# ------------------------------------# ------------------------------------# ------------------------------------
# ----------- SKUPINA A --------------# ----------- SKUPINA A --------------# ----------- SKUPINA A --------------# ----------- SKUPINA A --------------
#-------------------------------------#-------------------------------------#-------------------------------------#-------------------------------------

# ---------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------- 1. ULOHA --------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------

funkcia = function(n){
for(i in 1:n){
if ((i%%2)==0)
print(i^2)
else if ((i%%3)==0 && (i%%5)==0)
print(i^3)
else
print(i)
}
}

funkcia(15)

# ---------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------- 2. ULOHA --------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
getwd() # vypiste aktualnu cestu pracovneho adresara

setwd("C:/Users/Martina/Desktop/škola/Vysoká/2. ročník (B) LS/Simul. syst. v HI CL") # nastavi zapocet1
dir.create("Zapocet1") # vytvorte priecinok s nazvom Zapocet1
setwd("C:/Users/Martina/Desktop/škola/Vysoká/2. ročník (B) LS/Simul. syst. v HI CL/Zapocet1")
dir.create("data") #vytvorit priecinok data

fileUrl <- "http://web.tuke.sk/fei-cit/butka/res/irisdata.csv" #stiahnutie suboru
download.file(fileUrl, destfile = "data//SalesJan2009.csv") #nacitat data
list.files("data")

subor = read.csv2("data//SalesJan2009.csv") #nacitat do konzoly
head(subor, 10)
tail(subor, 15)
subor[1:5, 2:3]

podmnozina = read.csv("data//iris.csv", header = TRUE, colIndex=2:3, rowIndex=1:5)
search()

# ---------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------- 3. ULOHA --------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
set.seed(10)
install.packages("data.table")
library(data.table)
tabulka = data.table {A = rnorm(10),

}




### SKUPINA G
## --------------------------------------------------------------------------------------
## 1. ULOHA
funkcia=function(c,d,n){
f=seq(1,n,by=0.5)
for(i in 1:length(f)){
if(f[i]==c){
f[i]='A'
}
if(f[i]==d){
f[i]='B'
}

}
print(f)

}

funkcia(5,8,15)

## --------------------------------------------------------------------------------------
## 2. ULOHA
getwd()
dir.create("Zapocet1")
setwd("C:/Users/Martina/Desktop/zuzka/Zapocet1")
getwd()
install.packages("XML")
library(XML)
t = htmlParse("http://sport.aktuality.sk/vysledky/futbal/slovensko-fortuna-liga/tabulka/")
tabulky = readHTMLTable(t, stringAsFactor=FALSE)
tabulky
timy=tabulky[[1]][,c(2,3,8,4)]
names(timy)=c("tim", "zapasy", "skore", "body")
timy




### SKUPINA B 2017
## --------------------------------------------------------------------------------------
## 1. ULOHA
funkcia = function(a,b,n){
for(i in 1:n){

if(i %% a == 0){
result = i/a
print(result)
}

else if(i%%b == 0){
i = "B"
print(i)
}

else{
print(i)
}

}
}

funkcia(5, 3, 10)



## --------------------------------------------------------------------------------------
## 2. ULOHA
getwd()
dir.create("Zapocet1")
setwd("C:/Users/Martina/Desktop/Zapocet1")
library(XML)
t=htmlParse("http://sport.aktuality.sk/vysledky/futbal/slovensko-fortuna-liga/tabulka/")
tabulky= readHTMLTable(t, stringAsFactor=FALSE)
hokej = tabulky [[1]][, c(1, 2, 3, 8, 4)]
names(hokej) = c("Poradie", "Tim", "Zapasy", "Skore", "Body")
hokej




#skupina G
#(4.uloha)
library(datasets)
data(CO2)
CO2 = CO2
boxplot(CO2$uptake ~ CO2$Type, col ="green", main = "Boxplot of data CO2 attributes uptake and Type",
xlab = "Type", ylab ="uptake")
abline(h=25, lwd = 4, col = "red", lty = 2)

library(ggplot2)
data(CO2)
CO2 = CO2
qplot(uptake, col = Type, data=CO2, geom = "density")



#Skupina A
#4. uloha

library(datasets)
data(quakes)
quakes = quakes
par(mfrow = c(2, 1))
hist(quakes$long, col = "red", breaks = 15, main = "Histogram of attribute long")
hist(quakes$mag, col = "grey", breaks = 25, main = "histogram of attribute mag")

library(ggplot2)
data(quakes)
quakes = quakes
qplot(stations, data = quakes, geom = "density")




library(datasets)
data(infert)
infert = infert
boxplot(age ~ education, data = infert, col = "red", xlab = "education", ylab = "age", main = "Boxplot of data infert attributes age and education")
abline(h=30, lwd = 3, lty = 3, col = "blue")

library(lattice)
data(infert)
xyplot(stratum ~ age | education, data = infert)



#skupina B
#4.uloha
library(datasets)
data(CO2)
CO2 = CO2
boxplot(uptake~Treatment, data = CO2, col = "blue", main = "Boxplot of data CO2", xlab = "Treatment", ylab = "uptake")
abline(h=28, lwd=5, lty = 2, col = "red")

library(lattice)
data(CO2)
xyplot(uptake~conc | Type, data = CO2)



#skupina C
#4. uloha

library(datasets)
data(quakes)
quakes = quakes
par(mfrow= c(1,2))
with(quakes, plot(long,depth, col = "green", main="scatterplot of data quakes"))
with(quakes, plot(lat,depth, col = "blue", main="scatterplot of attributes lat and depth"))

library(ggplot2)
data(quakes)
qplot(lat, stations, data = quakes, col =mag)



#4.uloha 2018(moje)
#skupina A
library(datasets)
data(infert)
infert = infert
boxplot(pooled.stratum~parity, data = infert, col = "orange", main="Boxplot of data infert attributes pooled.stratum and parity", xlab="parity", ylab ="pooled.stratum")
abline(h=mean(infert$pooled.stratum), lwd=4, col ="blue", lty =3)

library(lattice)
data(infert)
par(mfrow=c(2,1))
pdf(file = "plot_zapocet.pdf")
boxplot(case ~ age | induced, data = infert)
dev.off()


#skupina B
library(datasets)
data(Theoph)
Theoph = Theoph
par(mfrow = c(1,2),las = 1) #las=orietacia označenia osi
plot(Theoph$Wt, Theoph$Dose, col = "blue", main = "Plot of data Theoph", xlab = "Wt", ylab = "Dose")
plot(Theoph$Wt, Theoph$conc, col= "red", main = "Plot of data Theoph attributes Wt and conc", xlab = "Wt", ylab = "conc")




#skupina C 2017

set.seed(18)
library("data.table")
tabulka = data.table(A=15:1,B=rep(factor(c("b","a","c")),each=5),D=15:1,C=rnorm(15))
tabulka$C [c(7,8)]=NA
summary(tabulka)
tabulka [,tabulka$D>0]
tabulka [tabulka$D,mean(D)]
sort(tabulka$C)
tabulka [,E:=sum(D),by=B]
tabulka [,F:=A^3]


library(datasets)
data(quakes)
quakes = quakes
par(mfrow=c(1,2), las=(1))
with(quakes, plot(long,depth,col="green",main="With of data quakes"))
with(quakes, plot(lat,depth, col="blue", main="With of data quakes"))


library(ggplot2)
data(quakes)
qplot(lat, stations, data=quakes, col=quakes$mag)


funkcia = function(a,b,n){
for(i in 1:n){
if(i<a){
print(i/4)
}
if((i==a) || ((i>a) && (i<b))){
print(i/3)
}
if((i==b) || ((i>b) && (i<n))){
print(i/2)
}
}
}
funkcia(5,2,3)




#zle zlee
getwd()
dir.create("Zapocticek")
setwd("Zapocticek")
library(jsonlite)
data_json = fromJSON("http://web.tuke.sk/fei-cit/butka/test/data.JSON")
names(data_json)
names(data_json$name)


funkcia = function(a,b,n){
for(i in a:n){
if(i<a){
print(i/4)
}
if((i==a) || ((i>a) && (i==b))){
print(i/3)
}
if((i==b) || ((i>b) && (i==n))){
print(i/2)
}
}
}
funkcia(2,3,5)


set.seed(18)
library("data.table")
tabulka = data.table(A=15:1,B=rep(factor(c("b","a","c")),each=5),D=15:1,C=rnorm(15))
tabulka$C [c(7,8)]=NA
summary(tabulka)
tabulka [,tabulka$D>0]
tabulka [tabulka$D,mean(D)]
sort(tabulka$C)
tabulka [,E:=sum(D),by=B]
tabulka [,F:=A^3]





download.file("http://people.tuke.sk/peter.butka/res/avgpm25.csv","avgpm25.csv")
pmdata = read.csv("avgpm25.csv", colClasses = c("numeric","character","factor", "numeric", "numeric"))

barplot(table(pmdata$region), col= "gold", main = "Number of counties in each region")

hist(pmdata$pm25, col="purple", breaks=150); rug(pmdata$pm25); abline(v = median(pmdata$pm25), col = "black", lwd = 4)

with(pmdata, plot(latitude,pm25)); abline(h = 1, lwd = 1,lty = 1);

par(mfrow = c(3, 1), mar = c(4, 4, 2, 1), oma = c(0, 0, 2, 0))
with(airquality, {
plot(Wind, Ozone, main = "Ozone and wind")
plot(Solar.R, Ozone, main = "Ozone and solar radiation")
plot(Temp, Ozone, main = "Ozone and temperature")
mtext("Ozone and weather in New York City", outer = TRUE)
})

library(rattle)
library(ggplot2)
cities <- c("Canberra", "Darwin", "Melbourne", "Sydney")
ds = subset(weatherAUS, Location %in% cities & ! is.na(Temp3pm))
p = ggplot(ds, aes(Temp3pm, colour=Location, fill=Location))
p = p + geom_density(alpha=0.55)
p

library(ggridges)
library(ggplot2)
head(diamonds)
ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
geom_density_ridges() +
theme_ridges() +
theme(legend.position = "none")

library("lattice")
data=matrix(runif(100, 0, 5) , 10 , 10)
colnames(data)=letters[c(1:10)]
rownames(data)=paste( rep("row",10) , c(1:10) , sep=" ")
par(mar=c(3,4,2,2))
levelplot(t(data[c(nrow(data):1) , ]))





#_________________1__________________________________________

x = c(1, 5, 4, 9, 5)
y = c(1, 5, 4, 9, 5)
i=1
f = function(x,y) {
for(i in 1:length(x))
{
z = x[i]+
print(z)
}

}

f(x)
#______________________________________2_________________________________________________

URL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv"
dir.create("data")
download.file(URL, destfile = "data.csv", method="curl")
dat = read.csv("data.csv", header = TRUE)
print(dat)

#______________________________________________3_________________________________________

tab = data.frame(Prvy= 1:10, Druhy = c(0.2, 0.7, NaN, 2.2,3.4), Treti=1:10, Stvrty=1:10, Piaty=1:10)
tab

tab[order(tab$Piaty),]
is.na(tab)
na.omit(tab)
#____________________________________________4______________________________________________

height <- c(145, 167, 176, 123, 150)
weight <- c(51, 63, 64, 40, 55)

plot(height,weight)


x <- seq(-pi,pi,0.1)
plot(x, sin(x))

pdf('filename.pdf')
plot(x, sin(x),
main="Graf",
ylab="daco",
type="l",
col="blue")
lines(x,cos(x), col="red")
legend("topleft",
c("sin(x)","cos(x)"),
fill=c("blue","red")

)
dev.off()


11 Mar 2019, 14:02
Profil  
Addict
Addict
Obrázok užívateľa

Registrovaný: 22.11.2006
Príspevky: 4357
Bydlisko: BA
Karma: Level +3
Príspevok Re: Ciferný súčet čísla v C
to si sa asi trosku sekol, nie? to su skripty z excelu, ziadne Cko.
sem si chcel dat ten kod ktory ti ma robit ciferny sucet cisel.

ale uz ti to tu napisali viaceri, miesto toho aby si ten sucet spravil jeden krat, budes ho opakovat pokial vysledok nebude iba jedna cifra.


11 Mar 2019, 19:07
Profil  
Amateur
Amateur
Obrázok užívateľa

Registrovaný: 25.9.2014
Príspevky: 34
Karma: Neutrál
Príspevok Re: Ciferný súčet čísla v C
-------------------------------------------- MARKDOWN -----------------------------------------------------------
---
title: "Cvicenie Markdown"
author: "Oliver"
date: "1 apríla 2019"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

#Technológie
##Technológie
###Technológie
####Technológie
#####Technológie

**Technológia** je chápaná ako ľudská činnosť. Technológia je staršia ako veda a inžinierstvo, pretože predstavuje ľudské znalosti pri riešení „skutočných“ bežných problémov pri vytváraní štandardizovaného vzhľadu a vlastností nástrojov, strojov, prístrojov, materiálov a procesov. Takáto štandardizácia dizajnu je základná vlastnosť technológií.

Technológia je náuka o výrobe materiálov a výrobkov z daných surovín, pričom nemusí nevyhnutne používať vedecké objavy a inžinierske konštrukcie.

Technológia sa zaoberá opisom techník poľnohospodárskej, priemyselnej a remeselnej výroby rôznych druhov tovaru, predmetov a látok človeku potrebných, ale aj opisom získavania a spracovania surovín používaných na výrobu.

Technológia môže byť intuitívne chápaná ako čisto empiricky podložená ľudská činnosť, ktorej postupmi a prostriedkami (technikami) vznikajú predmety pre rôzne ľudské potreby.

**Technológiu je možné chápať aj ako súbor všetkých technických vied.**

1. semester | 2. semester | 3. semester | 4. semester
----- | ----- | ----- | -----
A | F | K | P
B | G | L | Q
C | H | M | R
D | I | N | S
E | J | O | T

********

```{r}
hist(AirPassengers)

rnorm(25)
```

```{r, echo = FALSE}
rnorm(10)
```

```{r, echo = FALSE}
with(
mtcars,
plot(hp, wt, main = "Grafik")
)
```

********

#O mne
**Najradšej sledujem novinky z Apple a IT sveta** *a taktiež sa zaujímam o biografie rôznych úspešných ľudí.*
Budem pre vás tvoriť zaujímavé a originálne články práve do tejto kategórie.
> Verím, že pre vás bude moja tvorba inšpiráciou.

* Ja
* Ty
+ sestra
+ brat

superscript^2^
~~strikethrough~~
$A = \pi*r^{2}$
image:
![](path/to/smallorb.png)
Dva plus dva je `r 2 + 2`.
``` {r}
dim(iris)
```

``` {r, eval=FALSE}
dim(iris)
```

rmarkdown::render("myfile.Rmd")

```{r}
summary(cars)
```

```{r, echo=FALSE}
plot(cars)
```



------------------------------------------------------------------- PREZENTACIA -------------------------------------------------------------------------
---
title: "Untitled"
author: "Oliver"
date: "1 apríla 2019"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Slajd s odrážkami 1
Špeciálna technológia sa zaoberá zakonitosťami, princípmi, predpismi a metódami technologického procesu v rámci istého priemyselného odvetvia.

## Slajd s odrážkami 2
- **Názov 1**
- Špeciálna technológia sa zaoberá zakonitosťami, princípmi, predpismi a metódami technologického procesu v rámci istého priemyselného odvetvia.
- Názov 3

## Slajd s odrážkami 3
- Názov 1
- Názov 2
- Špeciálna technológia sa zaoberá zakonitosťami, princípmi, predpismi a metódami technologického procesu v rámci istého priemyselného odvetvia.

## Slajd s odrážkami 4
Špeciálna technológia sa zaoberá zakonitosťami, princípmi, predpismi a metódami technologického procesu v rámci istého priemyselného odvetvia.

## Slajd s odrážkami 5
- Špeciálna technológia sa zaoberá zakonitosťami, princípmi, predpismi a metódami technologického procesu v rámci istého priemyselného odvetvia.
- Názov 2
- Názov 3

--------------------------------------------------------------------- SHINY MARKDOWN -------------------------------------------------------------------------------

---
title: "zadanie"
author: "Oliver"
date: "1 apríla 2019"
output: html_document
runtime: shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

This R Markdown document is made interactive using Shiny. Unlike the more traditional workflow of creating static reports, you can now create documents that allow your readers to change the assumptions underlying your analysis and see the results immediately.

To learn more, see [Interactive Documents](http://rmarkdown.rstudio.com/authoring_shiny.html).

## Inputs and Outputs

You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive by wrapping it in the Shiny `renderPlot` function. The `selectInput` and `sliderInput` functions create the input widgets used to drive the plot.

```{r eruptions, echo=FALSE}
inputPanel(
selectInput("n_breaks", label = "Number of bins:",
choices = c(10, 20, 35, 50), selected = 20),

sliderInput("bw_adjust", label = "Bandwidth adjustment:",
min = 0.2, max = 2, value = 1, step = 0.2)
)

renderPlot({
hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
xlab = "Duration (minutes)", main = "Geyser eruption duration")

dens <- density(faithful$eruptions, adjust = input$bw_adjust)
lines(dens, col = "blue")
})
```

## Embedded Application

It's also possible to embed an entire Shiny application within an R Markdown document using the `shinyAppDir` function. This example embeds a Shiny application located in another directory:

```{r tabsets, echo=FALSE}
shinyAppDir(
system.file("examples/06_tabsets", package = "shiny"),
options = list(
width = "100%", height = 550
)
)
```

Note the use of the `height` parameter to determine how much vertical space the embedded application should occupy.

You can also use the `shinyApp` function to define an application inline rather then in an external directory.

In all of R code chunks above the `echo = FALSE` attribute is used. This is to prevent the R code within the chunk from rendering in the document alongside the Shiny components.


----------------------------------------------------------------------- UI ---------------------------------------------------------------

# This is the user-interface definition of a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#

library(shiny)

shinyUI(fluidPage(

### nazov aplikacie
titlePanel("appka"),




# Sidebar - bocny panel vykresleny v ramci celej app
sidebarLayout(
sidebarPanel(
#1.nastavenie vyberu moznosti(vyber farby)
radioButtons("colour","Colour of boxplot",choices=c("red","green","blue"),selected="red"),

checkboxGroupInput("variable", "Vyberte viacero moznosti",
c("A" = "a",
"B" = "b",
"C" = "c")),

textInput("caption", "Zadajte vstup", "a"),

fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),

#submitButton("Update View", icon("refresh")),

hr(), #ciara - ako enter

#2.nastavenie vyberu moznosti(vyber dat)
selectInput("select", label = h3("Vyber data pre summary"), choices = c("faithful", "cars", "quakes"), selected = "faithful"),
hr(),

dateInput("datum","Zadajte datum", value = Sys.Date(), format = "dd.mm.yyyy",
min = Sys.Date() - 5, max = Sys.Date()+ 5, language = "sk", startview = "year",
weekstart = 3),

dateRangeInput("datum2", "Zadajte rozsah",
start = Sys.Date() - 6, end = Sys.Date() + 4 ,min = NULL, max = NULL,
format = "yyyy-mm-dd", startview = "month", weekstart = 0,
language = "en", separator = "do"),
hr(),

fileInput("subor", "Nahrajte subor", multiple = TRUE,
accept = NULL),
actionButton("button","Potvrd"),

hr(),

actionLink("link","Zadajte link: "),

hr(),


numericInput("cislo", "Zadajte cislo", value = 18, min = 1, max = 25,
step = 3),

# submitButton("GO"),
#vnoreny panel
wellPanel(

textInput("text","Zadajte vstup", value = "a"),

actionButton("goButton", "Spust")

)

),


# Main panel for displaying outputs ----
mainPanel(

# Output: Tabset w/ plot, summary, and table ----
tabsetPanel(type = "tabs",
tabPanel("Histogram", plotOutput("distPlot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("distTable")), #vypis tabulky1
tabPanel("Data", dataTableOutput("data")), #vypis tabulky2
tabPanel("Text", verbatimTextOutput("distPrint"), #vypis textu2
textOutput("distText"), #vypis textu1
textOutput("Text3")) #vypis textu3

)

)

)
)
)


# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
fluidRow(column(12,dataTableOutput('table')))
)


--------------------------------------------------------------- SERVER -------------------------------------------------------------------------

library(shiny)

shinyServer(function(input, output) {


# Generate a summary of the data ----
output$summary <- renderPrint({
if(input$select == "faithful"){
summary(faithful)
} else if(input$select == "cars"){
summary(cars)
} else summary(quakes)
})


x <- reactive({as.numeric(input$text)+100})

output$distPlot <- renderPlot({

# generate bins based on input$bins from ui.R
x <- faithful[, 2]

#1.nastavenie vyberu moznosti(vyber farby)
if(input$colour == "red"){
mycol <- "red"
} else if (input$colour == "green"){
mycol <- "green"

} else mycol <- "blue"

# draw the histogram with the specified number of bins
boxplot(quakes, col = input$colour)

})

#vypis textu
output$distPrint <- renderPrint({
print(input$text)
})
#vypis tabulky1
output$distTable <- renderTable(iris)

#vypis tabulky2
output$data <- renderDataTable(faithful)

#vypis textu1
output$distText <- renderText({
paste("Zadali ste rozsah datumu ", input$datum2[1], " do ", input$datum2[2])
})

#vypis textu2
output$Text <- renderText({
x()
})

#vypis textu3
output$Text3 <- renderText({
input$goButton
isolate(paste("Zadali ste cisla ", input$text, " a" ,input$cislo))
})

})

------------------------ SPOLU -----------------------------
library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

# Application title
titlePanel("Old Faithful Geyser Data"),

# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("choices", "Vyberte atribut grafu", choices = colnames(state.x77)),
radioButtons("farba", label = "Zvolte farbu grafu", choices = c("red", "blue"), selected = "red"),
numericInput("riadky", label = "Zadajte rozdelenie v histograme", value = 12, min = 2, max = 20),
numericInput("riadkytab", label = "Pocet riadkov tabulky", value = 12, min = 1, max = 50)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
tableOutput("vypis")
)
)
)

# Define server logic required to draw a histogram
server <- function(input, output) {

output$distPlot <- renderPlot({

# draw the histogram with the specified number of bins
hist(state.x77[,input$choices], breaks = input$riadky, col = input$farba, border = 'white')
})

output$vypis <- renderTable({
head(state.x77,input$riadkytab)
})
}

# Run the application
shinyApp(ui = ui, server = server)



-------------------------------------------

library(shiny)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

# Application title
titlePanel("Old Faithful Geyser Data"),

# Sidebar with a slider input for number of bins
flowLayout(
numericInput("NumID","Pocet riadkov tabulky",value = 6,min = 1,max = 100,step = 5)
),

flowLayout(
selectInput("SelID","Vyberte atribut",choices=colnames(airquality)),
radioButtons("RadioID","Vyberte farbu grafu",choices=c("green","yellow")),
textInput("TextID", "Zadajte nadpis grafu",value = "Nadpis"),
tags$head(tags$script(src = "message-handler.js")),
actionButton("do", "Click Me")

),



# Show a plot of the generated distribution
mainPanel(
textOutput("textik"),
plotOutput("distPlot"),
tableOutput("tablee")
)
)
)

library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output, session){
observeEvent(input$do, {
session$sendCustomMessage(type = 'testmessage',
message = 'Thank you for clicking')


output$textik <- renderText({
vypis=c("Zobrazili ste tabuÄşku s 5 riadkami pre atribut Ozone ste nastavili farbu green")
print(vypis)

})

output$tablee <- renderTable({
airquality=c(input$NumID)
print(airquality)


})


output$distPlot <- renderPlot({

# generate bins based on input$bins from ui.R
x <- airquality[,input$SelID]
# bins <- seq(min(x), max(x), length.out = input$bins +1)

# draw the histogram with the specified number of bins
boxplot(x~airquality$Month, col = input$RadioID, border = 'white',main=input$TextID)

})

})
})


library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

output$distPlot <- renderPlot({

# generate bins based on input$bins from ui.R
x <- airquality[,input$selectID]
# ZAKOMENTOVAT !!!! bins <- seq(min(x), max(x), length.out = input$bins + 1)

# draw the histogram with the specified number of bins
boxplot(x~airquality$Month, col = input$radioID, border = 'white', main=input$textID)

})

})


library(shiny)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

output$textik <- renderText({
vypis=c("Vybrali ste si", input$radioID, "farbu a na porovnanie ste zadali atribúty ", input$selectID1, input$selectID2)
print(vypis)
})

output$distPlot <- renderPlot({

# generate bins based on input$bins from ui.R
# neviem ako zobrazit zaroven aj iny stlpec od selectID2
x <- quakes[, input$selectID1]
#bins <- seq(min(x), max(x), length.out = input$bins + 1)

# draw the histogram with the specified number of bins
hist(x, col =input$radioID, border = 'white', lwd=input$numericID)

})



})


----------------------------------------------------------------------- ROZDELENIA -------------------------------------------------------------------------

#PRAVDEPODOBNOSTNE ROZDELENIA v R

##normalove rozdelenie
# Generovanie 10 náhodných čísel z NR
rnorm(10,mean=0,sd=1)
# Hustota pravdepodobnosti v bude 10 (výška rozdelenia v bode 10)
dnorm(10,mean=0,sd=1,log=FALSE)
# Sumár hustoty pravdepodobnosti po daný bod (10) z ľava
pnorm(10, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
pnorm(1) # 0.8413447
pnorm(1,lower.tail=FALSE) # 0.1586553 od daného bodu napravo
pnorm(0)
# Inverzná k pnorm, vráti bod pri zadaní určitej pravdepodobnosti
qnorm(0.5) # 0
qnorm(0.85) # 1.036433
v=c(0.0,0.25,0.5,0.75,1.0) #vektor
qnorm(v) # [1] -Inf -0.6744898 0.0000000 0.6744898 Inf

##binomicke rozdelenie
rbinom(20, 100, prob = 0.1) #nahodne
rbinom(20, 100, prob = 0.5)
dbinom(20, 40, prob = 0.5) #hustota
pbinom(30, 40, p = 0.5) #sumar hustoty

#dalsie rozdelenia pravdepodobnosti - unif; pois; exp; chisq; geom; ...

runif(20, min = 0, max = 1)
rpois(20, lambda = 1)
dpois(20, lambda = 2, log = FALSE)
pexp(1, rate = 1, lower.tail = TRUE, log.p = FALSE)
rchisq(10, 2, ncp = 0)
rgeom(20, 0.5)

# Generovanie náhodných čísel
x <- rnorm(10)

# Sample - generovanie vzoriek
set.seed(1)
sample(1:10, 4) #generovanie 4 nahodnych cisel od 1 po 10
sample(letters, 5) #generovanie piatoch nahodnych pismen
sample(1:10) # permutácia prvkov od 1 do 10
sample(1:10, replace = TRUE) # výber s nahradením (môžu sa opakovať prvky)

set.seed(100)
rnorm(5) #generovanie 5 nahodnych cisel normaloveho rozdelenia


# Generovanie linearneho modelu
set.seed(20)
x <- rnorm(100)
e <- rnorm(100, 0, 2)
y <- 0.5 + 2 * x + e #linearna funkcia
summary(y)
plot(x, y) #graf xy
abline(lm(y~x)) #linearny model ako priamka v grafe


# Lineárne rovnice - riesenie pomocou SOLVE
A = matrix(nrow = 3, ncol = 3, data = c(6, 1, 2, 3, -3, 1, -2, 2, 1)) #prepis do matice A
b = c(2,5,9) #prepis do vektory b
solve(A,b) #riesenie rovnice pomocou prikazu SOLVE
A2 = matrix(nrow = 4, ncol = 4, data=c(4,3,2,5,-3,-2,-1,-3,2,1,0,1,-1,-3,5,-8))
b2 = c(8,7,6,1)
solve(A2,b2)

# Nelineárne rovnice - riesenie pomocou UNIROOT
# Príklad 2cos(x) - ln(x) = 0
#vykreslenie jednotlivych funkcii
curve(2*cos(x), 0, 10) #vykreslenie kosinusovej funkcie
curve(log(x), add = TRUE, col="red") #vykreslenie logaritmu
f = function(x) 2*cos(x) - log(x) #zapisanie funkcie
uniroot(f,lower=0,upper=2, tol=1e-9) #riesenie nelinearnej rovnice pomocou uniroot s ohranicenim (0,2) a presnostou
uniroot(f,lower=4,upper=6, tol=1e-9) #riesenie nelinearnej rovnice pomocou uniroot s ohranicenim (4,6) a presnostou
uniroot(f,lower=6,upper=7, tol=1e-9) #riesenie nelinearnej rovnice pomocou uniroot s ohranicenim (6,7) a presnostou

## x3+2x+4=0 - riesenie polynomialnej rovnice
polyroot(c(4,2,0,1))

# Lineárna regresia
x = c(3,8,9,3,13,6,11,21,1,16) #prepis vektora
y = c(30,57,64,72,36,43,59,90,20,83) #prepis vektora
mydata = data.frame(x,y) #vytvorenie tabulky
model = lm(y ~ x, data=mydata) #vytvorenie modelu linearnej regresie pomocou funkcie LM
plot(mydata) #zobrazenie dat v grafe
abline(model) #zobrazenie modelu v podobe priamky
pr1 <- data.frame(x = c(10,15,20))
pr1$y <- predict(model, newdata = pr1) #predikovanie hodnot

# Viacnásobná regresia
year <- rep(2008:2010, each = 4) #roky
quarter <- rep(1:4, 3) #kvartale
cpi <- c(162.2, 164.6, 166.5, 166, 166.2, 167,
168.6, 169.5, 171, 172.1, 173.3, 174) #hodnoty
plot(cpi, xaxt = "n", ylab = "CPI", xlab = "") #graf
# vykresli popis x-osi, kde 'las=3' zabezpeci vertikalny text
axis(1, labels = paste(year, quarter, sep = "Q"), at = 1:12, las = 3) #popis osi
fit <- lm(cpi ~ year + quarter)
data2011 <- data.frame(year = 2011, quarter = 1:4)
cpi2011 <- predict(fit, newdata = data2011) #predikovanie buducich hodnot
style <- c(rep(1, 12), rep(2, 4))
plot(c(cpi, cpi2011), xaxt = "n",ylab = "CPI", xlab = "",pch = style, col = style) #ich zobrazenie
axis(1, at = 1:16, las = 3,
labels = c(paste(year, quarter, sep = "Q"), "2011Q1", "2011Q2", "2011Q3", "2011Q4")) #zobrazenie osi s dalsimi kvartalmi


# Lineárne programovanie
# install.packages("lpSolveAPI")
library(lpSolveAPI)
lpmodel <- make.lp(0, 2) # prazdny LP solver s 2 premennymi
#prepis zadanej ulohy
lp.control(lpmodel, sense="max") # maximalizacia
set.objfn(lpmodel, c(143, 60)) # definicia KF (v anglictine casto objective function)
add.constraint(lpmodel, c(120, 210), "<=", 15000) #ohranicenia
add.constraint(lpmodel, c(110, 30), "<=", 4000) #ohranicenia
add.constraint(lpmodel, c(1, 1), "<=", 75) #ohranicenia
lpmodel #zobrazenie modelu
solve(lpmodel) #riesenie
get.objective(lpmodel) #hodnota KF (maximalna/minimalna)
get.variables(lpmodel) #hodnoty premennych X a Y pre optimum

# Celočíselné programovanie
# install.packages("lpSolve")
library(lpSolve)
assign.costs <- matrix (c(7, 7, 3, 2, 2, 7, 7, 2, 1, 9, 8, 2, 7, 2, 8, 10), 4, 4) #prepis
lp.assign (assign.costs) #sucet najmensich nakladov
lp.assign (assign.costs)$solution #riesenie v podobe matice


23 Apr 2019, 18:51
Profil  
Addict
Addict
Obrázok užívateľa

Registrovaný: 22.11.2006
Príspevky: 4357
Bydlisko: BA
Karma: Level +3
Príspevok Re: Ciferný súčet čísla v C
zalohovat na forum :D :D

pre vlastne dobro, bude sa ti to hodit aj do buducnosti, zacni radsej zalohovat na github.


24 Apr 2019, 8:13
Profil  
Expert
Expert
Obrázok užívateľa

Registrovaný: 12.6.2014
Príspevky: 161
Karma: Neutrál
Príspevok Re: Ciferný súčet čísla v C
Myslim, ze mame tu cest, ze na toto forum zavital pan Andrej.

IT Odborník Projekt DJ Andrej (nezostrihaná verzia)
YouTube
Názov videa: IT Odborník Projekt DJ Andrej (nezostrihaná verzia)
Autor: Mr. Mrožus
Zobrazení: 436369
Hodnotenie:
 
Odkaz na video: https://www.youtube.com/watch?feature=player_embedded&v=NOkLcZfjkC4


24 Apr 2019, 8:41
Profil  
Medium Professional
Medium Professional
Obrázok užívateľa

Registrovaný: 12.8.2006
Príspevky: 1087
Karma: Level +2
Príspevok Re: Ciferný súčet čísla v C
CrazyJerry pobavilo a asi to bude aj pravda :D


01 Máj 2019, 8:35
Profil  WWW
Zobraziť príspevky z predchádzajúceho:  Zoradiť podľa  
Odpovedať na tému  [ Príspevkov: 10 ] 


Kto je on-line 
Užívatelia prezerajúci fórum: Žiadny registrovaný užívateľ nie je prítomný a 2 hostia

Nemôžete zakladať nové témy v tomto fóre
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre
Nemôžete zasielať súbory v tomto fóre

Hľadať:
Skočiť na:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group. © Hojko 2004-2016
[ Time : 0.735s | 14 Queries | GZIP : On ]