#include <iostream> using std::cout; using std::cin; using std::endl; #include <cstring> using std::strlen;
int main() { char s[100]; char n;
cout << "Enter the string: "; cin.getline(s, 100);
for(int i = 0; i < strlen(s); i++) { if(s[i] == 'a') { n = 'a';
break; } else if(s[i] == 'o') { n = 'o';
break; } }
if(n == 'a') { cout << "\nThe first letter of A" << endl; } else if(n == 'o') { cout << "\nThe first letter of O" << endl; } else cout << "These letters are not available" << endl;
1) (первые 2 скриншота)
#include <iostream>
using std::cout;
using std::endl;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int main()
{
int a[10];
srand(time(0));
for(int i = 0; i < 10; i++)
{
a[i] = rand() % 101;
cout << a[i] << ' ';
}
cout << endl << endl;
for(int i = 0; i < 10; i++)
{
if(a[i] % 3 == 0 && a[i] > 13)
{
cout << a[i] << ' ';
}
}
cout << endl;
return 0;
}
2)
#include <iostream>
using std::cout;
using std::endl;
int main()
{
double a[10] = { 1.2, 0.0, -5.8, -0.4, 10.5, 14.6, -6.3, -8.8, -4.1, 0.0 };
int A = 0, B = 3;
for(int i = 0; i < 10; i++)
{
cout << a[i] << ' ';
if(a[i] < 0.0)
{
a[i] += a[A];
}
else if(a[i] == 0)
{
a[i] -= B;
}
}
cout << "\n\na(index) = " << A << ", b = " << B << "\n\n";
for(int i = 0; i < 10; i++)
{
cout << a[i] << ' ';
}
cout << endl;
return 0;
}
1)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char s[20];
cout << "What is your name: ";
cin >> s;
cout << "Hello, " << s << endl;
return 0;
}
2)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[100];
cout << "Enter the string: ";
cin.getline(s, 100);
for(int i = strlen(s) - 1; i >= 0; i--)
{
cout << s[i];
}
cout << endl;
return 0;
}
3)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[20];
bool x = true;
cout << "Enter the word: ";
cin.getline(s, 100);
for(int i = 0, j = strlen(s) - 1; i <= j; i++, j--)
{
if(s[i] != s[j])
{
x = false;
break;
}
}
if(x)
{
cout << "Palindrome" << endl;
}
else
cout << "Not palindrome" << endl;
return 0;
}
4)
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstring>
using std::strlen;
int main()
{
char s[100];
char n;
cout << "Enter the string: ";
cin.getline(s, 100);
for(int i = 0; i < strlen(s); i++)
{
if(s[i] == 'a')
{
n = 'a';
break;
}
else if(s[i] == 'o')
{
n = 'o';
break;
}
}
if(n == 'a')
{
cout << "\nThe first letter of A" << endl;
}
else if(n == 'o')
{
cout << "\nThe first letter of O" << endl;
}
else
cout << "These letters are not available" << endl;
return 0;
}