1、测试1

num = 8
if (num %% 2 == 0)
{
 print("even!") 
}

R语言中if判断语句

 

 

2、测试2

num = 7
if (num %% 2 == 0)
{
 print("even!") 
}

R语言中if判断语句

 

3、测试3

num = 7
if (num %% 2 == 0)
{
  print("even!")
} else
{
  print("odd!")
}

R语言中if判断语句

 

4、测试4

for (i in 1:10)
{
 if (i %% 2 == 0)
 {
   print(i)
 }
}

R语言中if判断语句

 

5、测试5

score <- 88
if (score >= 0 & score < 60)
{
 print("failed") 
} else
if (score >= 60 & score < 70) 
{
  print("pass") 
} else
if (score >= 70 & score < 90)
{
  print("brilliant")
} else
if (score >= 90 & score <= 100)
{
  print("excellant!")
} else
{
  print("input error")
}

R语言中if判断语句

 

相关文章:

  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2021-07-21
  • 2021-12-05
  • 2021-05-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2021-05-27
  • 2021-05-10
相关资源
相似解决方案