Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Еx 401

#include <iostream>
using namespace std;

int main() {
int arry[100],t = 0;
for (int r = 0; r < 100 ; r++)
{
cin >> arry[r];

if (arry [r] == -1){


break;
}
t += 1;
}
cout << t<< endl;
for (int r = 0; r < t ; r++){
cout << arry[r]<< " ";
}

Ех 402
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double arry[100];
int r;
for ( r = 0; r < 99; r++)
{
cin >> arry[r];
if (arry[r] == 0) break;
}
cout << r << endl;
for (int p = r - 1; p >= 0; p--)
cout << sqrt(arry[p])<<endl;

Еx 403
#include <iostream>
using namespace std;
int main()
{
int arry[1000],num;
cin >> num;
for (int r = 0; r < num; r++)
cin >> arry[r];
for (int r = 0; r < num; r++) {
if (arry[0] > arry[r])
{
arry[0] = arry[r];
}
}
cout << arry[0];
}

Ех 404
#include<iostream>
using namespace std;

int main(){
int nline[1000];
int num, mini;

cin >> num;


mini = 0;

cin >> nline[mini];

for ( int r = 1; r<num; r++){


cin >> nline[r];
if (nline[mini] > nline[r]){
mini = r;
}
}
cout << mini;
return 0;
}

Еx 405
#include <iostream>
using namespace std;

int main(){
int arry[1000], num, count = 0;
cin >> num;

for (int r = 0; r < num; ++r) {


cin >> arry[r];
}
int maximal = arry[0];
for (int r = 0; r < num; ++r) {
if ( arry[r] > maximal )
maximal = arry[r];
}
for (int r = 0; r < num; ++r) {
if ( maximal == arry[r] )
count++;
}
cout << count << endl;
return 0;
}

Ех 406
#include <iostream>
using namespace std;

int main(){
int letters, counter = 0;
cin >> letters;

char arry[letters];
for( int r = 0; r < letters; r++)
{
cin >> arry[r];
}
for( int r = 0; r < letters; r++)
{
if( arry[r] == 'A' )
counter ++;
}
cout << counter;
return 0;
}

Еx 407
#include <string.h>
#include <iostream>

using namespace std;

int main()
{
char inputt[1000];
int num;
cin >> num;
char letters[27] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
int countone[26] = { 0 };
for (int i = 0; i < num; i++)
cin >> inputt[i];

for (int i = 0; i < strlen(letters); i++) {


for (int j = 0; j < num; j++) {
if (inputt[j] == letters[i]) {
countone[i]++;
}
}

}
int countertwo = 0;
for (int i = 0; i < 26; i++) {
if (countone[i] > 0)
countertwo++;
}
cout << countertwo << endl;
for (int i = 0; i < 26; i++) {
if (countone[i] > 0)
cout << letters[i] << " " << countone[i] << endl;
}
return 0;
}

Ех 408
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int arry[1000], nn;
cin >> nn;
for ( int ii = 0; ii < nn; ii++)
{
cin >> arry[ii];
}

for (int r = 0; r < nn; r++) {


for (int vv = 0; vv < nn - 1 - r; vv++) {
if (arry[vv] > arry[vv + 1]) {
swap(arry[vv], arry[vv + 1]);
}
}
}
for (int yy = 0; yy < nn; yy++) {
cout << arry[yy] << " ";
}
return 0;
}

Еx 409
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
int arr[n][3];
for (int i = 0, temp; i < n; i++)
{
for (int r = 0; r < 3; r++)
{
cin >> arr[i][r];
}
}
for (int i = 0; i < n - 1; i++)
{
for (int r = 0; r < n - i - 1; r++)
{
if ((arr[r][0] > arr[r + 1][0]) || (arr[r][0] == arr[r + 1][0] &&
arr[r][1] > arr[r + 1][1]) ||
(arr[r][0] == arr[r + 1][0] && arr[r][1] == arr[r + 1][1]
&&
arr[r][2] > arr[r + 1][2]))
swap(arr[r], arr[r + 1]);
}
}
for (int i = 0; i < n; i++)
{
for (int r = 0; r < 3; r++)
{
cout << arr[i][r] << " ";
}
cout << endl;
}
return 0;
}

Ех 410
#include <iostream>
using namespace std;

int main() {
int number;
bool check = true;
cin >> number;

for (int r = 2; r <= number / 2; ++r)


{
if (number % r == 0)
{
check = false;
break;
}
}
if ( check == true )
{
cout << "YES";
}
else
{
cout << "NO";
}
return 0;
}

Еx 411
#include <iostream>
using namespace std;

int main()
{
int numbr ;
cin >> numbr;
cout << 2 <<" ";

for(int z = 2; z <= numbr; z++)


{
for(int xx= 2; xx < z; xx++ )
{
if(z % xx == 0)
{
break;
}
if(xx == z - 1 )
{
cout << z << " ";
}
}
}
return 0;
}

You might also like