Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xt<-function(n, nmin=4){
- #error handling
- if(class(n)!="numeric"){stop("Must be numeric.")}
- if(floor(n)!=n){stop("Must be whole number.")}
- if(n<nmin){stop("n must be at least nmin.")}
- #set up vector for rows
- v<-vector("character", (2*n)-1)
- #determine length of each row of stars.
- for(i in 1:(n-1)){
- mid<-(length(v)+1)/2
- lbound<-mid-(i-1)
- rbound<-mid+(i-1)
- #fill in each row of stars.
- for(j in lbound:rbound){
- v[j]<-"*"
- }
- print(noquote(v))
- }
- #put in the last row for the stem.
- v<-vector("character", (2*n)-1)
- v[mid]<-"*";print(noquote(v))
- }
- xt(15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement