#include <iostream>
using namespace std;
int main() {
string text1 = "C++";
string text2 = "Python";
cout << "Before Swapping:" << endl;
cout << "text1 = " << text1 << endl;
cout << "text2 = " << text2 << endl;
text1.swap(text2);
cout << "\nAfter Swapping:" << endl;
cout << "text1 = " << text1 << endl;
cout << "text2 = " << text2;
return 0;
}
using namespace std;
int main() {
string text1 = "C++";
string text2 = "Python";
cout << "Before Swapping:" << endl;
cout << "text1 = " << text1 << endl;
cout << "text2 = " << text2 << endl;
text1.swap(text2);
cout << "\nAfter Swapping:" << endl;
cout << "text1 = " << text1 << endl;
cout << "text2 = " << text2;
return 0;
}
👍1
يطبع الكود السابق هذا الخرج Before Swapping:
text1 = C++
text2 = Python After Swapping: text1 = Python text2 = C++
text1 = C++
text2 = Python After Swapping: text1 = Python text2 = C++
Anonymous Quiz
51%
صح
49%
خطا
👎3👍2❤1
#include <iostream>
using namespace std;
int main() {
string text = "Hasta la vista!\nbaby!";
cout << text;
return 0;
}
using namespace std;
int main() {
string text = "Hasta la vista!\nbaby!";
cout << text;
return 0;
}
👍1
❤1
#include <iostream>
using namespace std;
int main() {
string text1 = "Batman";
string text2 = "Joker";
string text3 = "Riddler";
text2.swap(text1);
text3.swap(text2);
cout << text1 << endl;
cout << text2 << endl;
cout << text3;
return 0;
}
using namespace std;
int main() {
string text1 = "Batman";
string text2 = "Joker";
string text3 = "Riddler";
text2.swap(text1);
text3.swap(text2);
cout << text1 << endl;
cout << text2 << endl;
cout << text3;
return 0;
}
❤1👍1
#include <iostream>
using namespace std;
int main() {
string text1 = "Smoke";
string text2 = "On The";
string text3 = "Water";
cout << text1 + " " + text2 + text3;
return 0;
}
using namespace std;
int main() {
string text1 = "Smoke";
string text2 = "On The";
string text3 = "Water";
cout << text1 + " " + text2 + text3;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int x[3] = {8, 16, 24};
*x = 5;
cout << *x;
return 0;
}
using namespace std;
int main() {
int x[3] = {8, 16, 24};
*x = 5;
cout << *x;
return 0;
}
👍2
❤2
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 1; ++j) {
cout << "*" << endl;
}
}
return 0;
}
using namespace std;
int main() {
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 1; ++j) {
cout << "*" << endl;
}
}
return 0;
}