输入一个1-7的数值,然后输出相应的英文单词,要求分别使用指针数组和stri

输入一个1-7的数值,然后输出相应的英文单词,要求分别使用指针数组和string类

第1个回答  2016-11-03
#include <iostream>
using namespace std;
int main()
{
    char *str[7] = {"one","two", "three", "four", "five", "six", "seven"};
    int i;
    cin >> i;
    cout << str[i] << endl;
    return 0
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str[7] = {"one","two", "three", "four", "five", "six", "seven"};
    int i;
    cin >> i;
    cout << str[i] << endl;
    return 0
}

本回答被网友采纳
相似回答