Задание №120

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <string> #include <cmath> using namespace std; int main() { double x; double a[3]; string namef[3]={"sin(x)","cos(x)","ln(x)"}; int ind[3]={0,1,2}; int n=3; cout<<"Введите х "; cin>>x; if(x<=0) { cout<<"ln(x) не определен"<<endl; if(sin(x)>cos(x)) cout<<"cos(x)="<<cos(x)<<"; sin(x)="<<sin(x)<<endl; else cout<<"sin(x)="<<sin(x)<<"; cos(x)="<<cos(x)<<endl; } else { a[0]=sin(x); a[1]=cos(x); a[2]=log(x); double dtmp; int tmp; for(int i=0;i<n-1;++i) for(int j=0;j<n-1;++j) if (a[j+1]<a[j]) { dtmp=a[j+1]; a[j+1]=a[j]; a[j]=dtmp; tmp=ind[j+1]; ind[j+1]=ind[j]; ind[j]=tmp; } cout<<namef[ind[0]]<<"="<<a[0]<<"; "<<namef[ind[1]]<<"="<<a[1]<<"; "<<namef[ind[2]]<<"="<<a[2]<<"; "<<endl; } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines