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
那麼,你現在做... –