仅使用顺序结构解题

P2433 【深基1-2】小学数学 N 合一

AUAKAC @ 2021-03-23 20:57:10

这道题被划分在了顺序结构入门题库中,严谨的来说,应该使用基本的输入输出来进行解题,不知道有没有大佬可以仅用顺序结构来解题?


by Eon_Sky @ 2021-03-23 20:59:16

三目运算符,但是if应该算的上顺序结构


by _SkyBlue @ 2021-03-23 20:59:32

不要找茬儿好么


by Coros_Trusds @ 2021-03-23 21:00:39

lz吃撑了罢


by ud2_ @ 2021-03-23 21:03:03

顺 序 结 构

int main() {
  unsigned type;
  scanf("%u", &type);
  puts(((const char* []) {
    "I love Luogu!",
    "6 4",
    "3\n12\n2",
    "166.667",
    "15",
    "10.8167",
    "110\n90\n0",
    "31.4159\n78.5398\n523.599",
    "22",
    "9",
    "33.3333",
    "13\nR",
    "16",
    "50"
  })[--type]);
  return 0;
}

by _caiji_ @ 2021-03-23 21:04:51

打表算顺序结构吧。

#include <cstdio>
using namespace std;
const char* db[]={"naive","I love Luogu!","6 4","3\n12\n2","166.667","15","10.8167","110\n90\n0","31.4159\n78.5398\n523.599","22","9","33.3333","13\nR","16","50"};
int main(int T,char**){
    scanf("%d",&T);
    printf("%s",db[T]);
    return 0;
}

by CGDGAD @ 2021-03-23 21:06:11

@AUAKAC 这题可以被拆成好几个可以使用顺序结构做的小题目。

当然合在一起就通常不是顺序结构了。


by _caiji_ @ 2021-03-23 21:08:01

这主要看你对"顺序结构"的定义。


by 庄nnnn额 @ 2021-07-26 09:42:30

@caijianhong +1


|