上一页 1 ··· 296 297 298 299 300 301 302 303 304 ··· 367 下一页
摘要: c语言中使程序执行任意次数。 (1)、可选的任意次数 do语句 #include <stdio.h> int main(void) { int j; do { int i; puts("please input an integer."); printf("i = "); scanf("%d", & 阅读全文
posted @ 2021-04-18 18:09 小鲨鱼2018 阅读(488) 评论(0) 推荐(0) 编辑
摘要: c语言中程序的循环控制,do语句输入两个整数,计算它们之间的所有整数的和。 1、do语句 #include <stdio.h> int main(void) { int a, b, min, max, sum = 0; puts("please input two integers."); prin 阅读全文
posted @ 2021-04-18 17:46 小鲨鱼2018 阅读(1291) 评论(0) 推荐(0) 编辑
摘要: 1、奇数 #include <stdio.h> int main(void) { int i; puts("please input an integer."); printf("i = "); scanf("%d", &i); while(i > 0) { if (i % 2) printf("% 阅读全文
posted @ 2021-04-18 12:49 小鲨鱼2018 阅读(345) 评论(0) 推荐(0) 编辑
摘要: linux系统中sort命令。 1、测试数据 [root@centos7 test2]# cat a.txt google 110 5000 baidu 100 5000 guge 50 3000 sohu 100 4500 2、默认按照第一列排序 [root@centos7 test2]# sor 阅读全文
posted @ 2021-04-17 23:25 小鲨鱼2018 阅读(283) 评论(0) 推荐(0) 编辑
摘要: R语言中rnorm函数。(正态分布) 1、基本用法 norm(n, x, y): 产生n个平均数为x,标准差为y的数。 默认情况下,平均数为0, 标准差为1. > a <- rnorm(10) > a [1] 0.08629733 -0.31750665 1.51152649 -0.60992255 阅读全文
posted @ 2021-04-17 22:57 小鲨鱼2018 阅读(4664) 评论(0) 推荐(0) 编辑
摘要: 1、 dat <- data.frame(v1=sample(1:15,15),v2=sample(1:15,15)) dat$cat[dat$v1 <= 8] <- "SMALL" dat$cat[dat$v1 > 8 ] <- "BIG" 2、 dat <- data.frame(v1=samp 阅读全文
posted @ 2021-04-17 20:42 小鲨鱼2018 阅读(4863) 评论(0) 推荐(0) 编辑
摘要: R语言中求数据框每一列的最大值、最小值、平均数、中位数、方差和标准差 1、 d <- data.frame(v1=sample(1:10,6),v2=sample(1:10,6),v3=sample(1:10,6), v4=sample(1:10,6)) rmax <- vector() rmin 阅读全文
posted @ 2021-04-17 18:29 小鲨鱼2018 阅读(14919) 评论(0) 推荐(0) 编辑
摘要: 1、测试数据 a <- c(8,4,7,6,2,5) 2、最大值、最小值 > max(a) [1] 8 > min(a) [1] 2 3、平均数、中位数 > mean(a) [1] 5.333333 > median(a) [1] 5.5 4、方差、标准差 > var(a) [1] 4.666667 阅读全文
posted @ 2021-04-17 18:15 小鲨鱼2018 阅读(9247) 评论(0) 推荐(0) 编辑
摘要: 当数据的维度超过2时,可以使用数组。 1、创建数组。2行3列2面的数组 dim1 <- c("a1","a2") dim2 <- c("b1","b2","b3") dim3 <- c("c1","c2") a <- array(1:12,c(2,3,2),dimnames = list(dim1, 阅读全文
posted @ 2021-04-17 16:41 小鲨鱼2018 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 1、 for (i in 1:10) { print("hello,world!") } 2、 for (i in 1:10) { print(i) } 3、 sum = 0 for (i in seq(1,100,1)) { sum = sum + i } print(sum) 4、求二维数组中的 阅读全文
posted @ 2021-04-17 16:07 小鲨鱼2018 阅读(2207) 评论(0) 推荐(0) 编辑
上一页 1 ··· 296 297 298 299 300 301 302 303 304 ··· 367 下一页