Δημοσιεύτηκε: 22 Ιουν 2010, 11:27
Να γράψετε ένα πρόγραμμα στην C++ το οποίο θα διαβάζει 5 ονόματα και θα εμφανίζει δίπλα από το όνομα το μήκος (length).
- Κώδικας: Επιλογή όλων
#include <iostream>
using namespace std;
int main (void)
{
string x;
int i;
int a [5];
string b[5];
for(i=0; i<=4; i++){
cout << "Using your keyboard insert your text.\n";
cout << ">> ";
cin >> x;
a[i]=x.length();
b[i]=x;}
cout << "===============================" << endl;
for(i=0; i<=4; i++){
cout << b[i] << " = " << a[i] <<endl;}
return 0;}