Sunteți pe pagina 1din 2

ex4

#include <iostream>
#include <string>
using namespace std;
string s,l;
int x;
bool t;
int main() {
getline(cin, s);
for (x = 0; x < s.length(); x++) {
l = s[x];
if (stoi(l) % 2 == 0) t=true;
}
if (t == true) cout << "Da, se poate forma cel putin un numar par.";
else cout << "Nu, nu se poate forma un numar par.";

return 0;
}
ex5
#include <iostream>
using namespace std;
string c[4],s;
int x,y;
bool t;
int main() {
cout << "Dati cele 4 cuvinte : "<<endl;
for (x = 0; x <= 3; x++)
cin >> c[x];
cout << "Ati introdus :"<<endl;
for (x = 0; x <= 3; x++)
cout << c[x]<<endl<<endl;

for (x = 0; x <= 3; x++)


s = s + c[x] + ' ';
y = s.length();
s[y - 1] = '.';

cout << "Rezultat : \nVariabila de tip [s] string contine acum : \n" << s;
cout << endl << endl << endl;

return 0;
}

ex6

#include <iostream>
using namespace std;
string c1, c2, c3, c4 , s;
int x,y;
bool t;
int main() {
cout << "Dati cele 4 cuvinte : "<<endl;
cin >> c1; cin >> c2; cin >> c3; cin >> c4;
cout << endl << endl << endl;
cout << "Ati introdus :"<<endl;
cout<< c1<<endl; cout << c2 <<endl; cout << c3 <<endl; cout << c4 <<endl;
cout << endl << endl;
y = c4.length() / 2;
s = s+ c1[0] + c1[1] + c2[0] + c3[0]+c3[1]+c3[2];
for (x = 0; x < y; x++) s = s + c4[x];

/*
iarp
nyu
dogfu
werjfdgu

iandogwerj
*/

cout << "Rezultat : \n" << s;

return 0;
}

S-ar putea să vă placă și