forked from Nastasia8/informatics_42_2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int x,y[0],s,s1,k,n,m,q,w,x1; | ||
cout <<"Введите число: "; | ||
if (cin>>x) | ||
{ | ||
s=0; | ||
x1=x; | ||
while (x) | ||
{ | ||
x=x/10; | ||
s++; | ||
} | ||
k=0; | ||
n=10; | ||
m=1; | ||
s1=0; | ||
q=0; | ||
w=0; | ||
while (s!=s1) | ||
{ | ||
y[k]=x1%n/m; | ||
s1++; | ||
n=n*10; | ||
m=m*10; | ||
q=y[k]%2; | ||
if (q==0) | ||
{ | ||
w=w+y[k]; | ||
} | ||
} | ||
cout <<endl<<"Сумма чётных чисел = "<<w; | ||
return 0; | ||
|
||
} | ||
else | ||
{ | ||
goto eror; | ||
} | ||
eror: | ||
cout <<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<< "Введённые символы некоректны"; | ||
return 0; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
double x,y,z,D,f1,f2; | ||
cout <<"Введите переменную x : "; | ||
if (cin>>x) | ||
{ | ||
cout <<"Введите переменную y : "; | ||
if (cin>>y) | ||
{ | ||
cout <<"Введите переменную z : "; | ||
if (cin>>z) | ||
{ | ||
D=pow(y,2)-4*x*z; | ||
cout <<"Дискриминант = "<<D<<endl<<endl; | ||
if (D<0) | ||
{ | ||
cout <<"Корней нет"; | ||
return 0; | ||
} | ||
if (D==0) | ||
{ | ||
f1=-y/(2*x); | ||
cout <<"Корень уравнения: "<<f1; | ||
return 0; | ||
} | ||
if (D>0) | ||
{ | ||
f1=(-y+pow(D,0.5))/(2*x); | ||
f2=(-y-pow(D,0.5))/(2*x); | ||
cout <<"Первый корень уравнения: "<<f1<<endl<<"Второй корень уравнения: "<<f2; | ||
return 0; | ||
} | ||
} | ||
else | ||
{ | ||
goto eror; | ||
} | ||
} | ||
else | ||
{ | ||
goto eror; | ||
} | ||
} | ||
else | ||
{ | ||
goto eror; | ||
} | ||
|
||
eror: | ||
cout <<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<< "Введённые символы некоректны"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <iostream> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
|
||
int x,y,s,s1,f[0],x1,w,n,m,k; | ||
void fun () | ||
{ | ||
while (s!=s1) | ||
{ | ||
f[k]=x1%n/m; | ||
s1++; | ||
n=n*10; | ||
m=m*10; | ||
w=w*f[k]; | ||
} | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
zan: | ||
cout <<"Введите шестизначное число: "; | ||
if (cin>>x) | ||
{ | ||
x1=x; | ||
s=0; | ||
s1=0; | ||
n=10; | ||
m=1; | ||
k=0; | ||
w=1; | ||
while (x) | ||
{ | ||
x=x/10; | ||
s++; | ||
} | ||
if (s==6) | ||
{ | ||
fun (); | ||
cout <<endl<<"Произведение цифр данного числа: "<<w; | ||
return 0; | ||
} | ||
else | ||
{ | ||
cout <<endl<<"Введено не шестизначное число"<<endl; | ||
goto zan; | ||
} | ||
} | ||
else | ||
{ | ||
goto eror; | ||
} | ||
|
||
eror: | ||
cout <<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<< "Введённые символы некоректны"; | ||
return 0; | ||
} |