1)
program pr;
uses crt;
Var y,x:real;
Begin
Writeln('vvedite x');
readln(x);
y:=(4*x)/(x-1);
Writeln('y=',y:10:3);
readln;
end.
2)
program pr;
Var n,i,a:integer;
Begin
Writeln('введите кол-во цыфр');
readln(n);
for i:=1 to n do Begin
readln(a);
if (a>9) and (a<1000) and (a mod 10=4) then Writeln(a);
end;
end.
2) использование массива
program pr;
uses crt;
Var n,i:integer;
a:array[1..100] of integer;
Begin
Writeln('Введите кол-во цифр');
readln(n);
Writeln('Введите цифры');
for i:=1 to n do read(a[i]);
Writeln;
for i:=1 to n do
if (a[i]>9) and (a[i]<1000) and (a[i] mod 10=4) then Write(a[i],';');
end.
#include "stdafx.h"
#include<iostream>
#include<time.h>
#include<list>
using namespace std;
const int N = 15;
list<int> A;list<int> C;
void print(list<int> x){
while(!x.empty()){
cout<<x.front()<<" ";
x.pop_front();}
}
void make(list<int>& x){
for (int i = 0; i < N;i++){
x.push_back(rand()%29+1);
}
}
void main(){
srand(time(NULL));
make(A);
list<int> tmp = A;
print(A);
_01:cout<<"\nWrite digit to change: ";int digit(0); cin>>digit;
A.remove(digit);//удаляю введене число
int newdigit = digit+15;// збільшую нове число, щоб не повторилось случайно з видаленим
int size = N - A.size();//узнаю скільки чисел удалило
for (int i = 0; i < size; i++) A.push_back(rand()%newdigit+1); //добавляю нові значення замість видалених
if (size!=0){
cout<<"OK\nAFTER CHANGE\n";
print(A);cout<<endl;
}
else {cout<<"What you want to change?? digit not exist!!"; goto _01;}
int n(0),k(0);
cout<<"Delete n element from k position Write n: ";cin>>n;
cout<<"Write k ";cin>>k;
int cout1(0);
list<int>::iterator m;
m = A.begin();
for (int i = 0; i < k; i++) *m++;
for (int i = 0; i < n; i++) {
A.remove(*m++); cout1++;//бо так нада
}
int how = N - A.size() - n;
for (int i = 0; i< how; i++) A.push_back(rand()%29+1);
print(A);list<int> B = A; int sizeB = B.size();
cout<<"\nAFTER CONCAT C = \n";
for (int i = 0 ; i < N; i++) {C.push_back(tmp.front()++); tmp.pop_front();}
for (int i = 0 ; i < sizeB; i++) {C.push_back(B.front()++); B.pop_front();}
cout<<endl;
print(C);
cout<<"\n";
system("pause");
}