Arkanium77

Untitled

Apr 25th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <cstring>
  6.  
  7. using namespace std;
  8.  
  9. struct da{
  10.     int d, m, y;
  11. }dd;
  12. int const n=4;
  13. struct stud{
  14.     string name;
  15.     da dd;
  16.     int mark[n];
  17.     double m;
  18. };
  19.  
  20. int main(){
  21.     int k;
  22.     cout<<"Введите количество студентов"<<'\n';
  23.     cin>>k;
  24.     stud *p;
  25.     srand(time(NULL));
  26.     p=new stud[k];
  27.     da.dd *q;
  28.     q=new da[k];
  29.     for(int i=0; i<k; i++){
  30.         cout<<endl<<"Введите фамилию:"<<'\n';
  31.         cin>>(p+i)->name;
  32.         cout<<endl<<"Введите оценки по предметам: алгебра, геометрия, СИиКТ, история"<<'\n';
  33.         for(int j=0; j<n; j++){
  34.             cin>>(p+i)->mark[j];
  35.             ((p+i)->m)+=(p+i)->mark[j];
  36.         }
  37.         ((p+i)->m)/=n;
  38.         ((p+i)->((q+i)->d))=rand()%30+1;
  39.         ((p+i)->((q+i)->m))=rand()%12+1;
  40.         ((p+i)->((q+i)->y))=rand()%5+1995;
  41.        
  42.         cout<<endl<<"Дата рождения:"<<((p+i)->((q+i)->d))<<'.'<<((p+i)->((q+i)->m))<<'.'<<((p+i)->((q+i)->y))<<'\n';
  43.         cout<<"Средняя оценка:"<<((p+i)->m)<<'\n';
  44.     }
  45. }
  46. //_______________________________________________-----------------+++++++++++++++++++++
  47. #include <iostream>
  48. #include <cmath>
  49. #include <cstdlib>
  50. #include <ctime>
  51.  
  52. using namespace std;
  53.  
  54. int main(){
  55.     struct complex{
  56.         double x, y;
  57.     };
  58.    
  59.     complex *p;
  60.     int n, nmax;
  61.     double max;
  62.     cout<<"Введите размерность:"<<'\n';
  63.     cin>>n;
  64.    
  65.     p=new complex[n];
  66.     cout<<"Введите комплексное число:"<<'\n';
  67.     for(int i=0; i<n; i++){
  68.         cin>>(p+i)->x>>(p+i)->y;
  69.     }
  70.     nmax=0;
  71.     max=sqrt(p->x*p->x+p->y*p->y);
  72.     for(int i=1; i<n; i++){
  73.         double tmp=sqrt((p+i)->x*(p+i)->x+(p+i)->y*(p+i)->y);
  74.         if (tmp>max){
  75.             max=tmp;
  76.             nmax=i;
  77.         }
  78.     }
  79.     cout<<"max="<<max<<'\n';
  80.     cout<<"N="<<nmax+1<<'\n';
  81. }
Advertisement
Add Comment
Please, Sign In to add comment