zoukankan      html  css  js  c++  java
  • [OI

    有关二维字符型数组的读入


    今天LYOI日常模拟赛
    窝因为T3读入二维字符型数组时出了锅导致爆零qwq

    步入正题

    那么该如何读入二维的字符型数组呢
    假设我们想读入n = 6的二维字符型数组

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    
    using namespace std;
    //#define DEBUG(x) cerr << #x << "=" << x << endl
    char a[100][100];
    
    int main()
    {
    	int n = 6;
    	for (int i = 1; i <= n; i++)
    	{
    		scanf("%s", a[i]);
    	}
    	for (int i = n; i >= 1; i--)
    	{
    		printf("%s
    ", a[i]);
    	}
    	return 0;
    }
    

    因为scanf读入的是一维的
    所以我们只需要读入a[n]即可
    这样就变成了二维
    如果我们输入

    W
    Q
    Z
    X
    love
    I
    

    那么我们运行程序,即可得到结果

    I
    love
    X
    Z
    Q
    W
    

    没错这看似很简单
    实际上就是很简单....qwq
    qwq...我菜爆了
    距离NOIP2018仅剩8天
    祝各位++RP

  • 相关阅读:
    json数据读取后自动进行模板生成
    json数据排序
    fastjson json数据处理
    xml数据转Json
    jackson-dataformat-xml xml转json
    jar工具打包
    工具操作
    IBM MQ
    RabbitMq
    Excel4J
  • 原文地址:https://www.cnblogs.com/aiyi2000/p/9886411.html
Copyright © 2011-2022 走看看