100篇打点!

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/csdn_kou/article/details/82417138

原创终于到100了,写一篇博客打点。在记录一个很严重的问题,昨天面试,程序的思路都有了,可是在线OJ半天无法将多个字符串输入并保存,遍历。现在记录一下方法!

#include <stdio.h>
#include <stdlib.h>
int main()
{
    char str[10][100];
    int i;
    for (i = 0; i < 10; i++)
        scanf("%s", str[i]);//逐个输入。
    for (i = 0; i < 10; i++)
        printf("%s\n", str[i]);//将输入的字符串依次输出以确认结果
    system("pause");
    return 0;
}

c++版本


int main()
{
    vector< string> array(10);

    for (int i = 0; i < 10; i++)
        cin >> array[i];

    for (int i = 0; i < 10; i++)
            cout << array[i] << endl;

}

猜你喜欢

转载自blog.csdn.net/csdn_kou/article/details/82417138