0
我是新来的C++,但确实有编码的基本知识。这个程序运行良好,但我想知道是否有更好的方法来做到这一点。有没有更好的方法?新来的c + +
该程序通过取您姓氏的前三个字母和您的名字的前两个字母来创建您的星球大战名字的第一个名称,从而形成一个星球大战的名称。然后你星球大战姓它需要你母亲的娘家姓的前两个字母,你出生在城市的前三个字母。
// starWarsName.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string firstName;
string surname;
string maidenName;
string city;
cout << "This program is designed to make you a star wars name, it takes some information and concatinates parts of the information to make your NEW name" <<endl << endl;
cout << "please enter your first name" << endl;
cin >> firstName;
cout << "please enter your surname" <<endl;
cin >> surname;
cout << "what is your mothers maiden name?" << endl;
cin >> maidenName;
cout << "please tel me which city you were born in" << endl;
cin >> city;
cout << firstName << " " << surname << endl;
cout << firstName[0] << " " << surname << endl;
int size = firstName.length();
//cout << size;
cout << surname[0] << surname[1] << surname[2] << firstName[0] << firstName[1];
cout << " " << maidenName[0] << maidenName[1] << city[0] << city[1] << city[2];
cin.get();
cin.ignore();
return 0;
}
张贴在http://codereview.stackexchange.com/。 –
感谢您的反馈,没有使用堆栈交换足以知道该怎么做。 – deadstone1991
那么,你现在做... –