fork(3) download
  1. /*
  2. 5-1. Даны действительные числа a1901,a1902,..,a1950 - количество осадков (в миллиметрах),
  3. выпавших в Москве в течение первых 50 лет нашего столетия.
  4. Надо вычислить среднее количество осадков и отклонение от среднего для каждого года.
  5. */
  6. #include <iostream>
  7. const n=50;
  8. double mas[n];
  9. int i;
  10. double sr;
  11.  
  12. int main()
  13. {
  14. setlocale(LC_ALL, "");
  15. input();
  16. std::cout << "Среднее кол-во осадков="<<sr<<".";
  17. proc();
  18. }
  19.  
  20. void input(){
  21. sr=0;
  22. for(int i=1;i<n;i++){
  23. clrscr();
  24. std::cout << "Введите кол-во осадков в "<<i+1900<<" году.";
  25. std::cin>>mas[i];
  26. sr=sr+mas[i];
  27. }
  28. sr=sr/n;
  29. }
  30. void proc(){
  31. for(int i=1;i<50;i++){
  32. if(mas[i]>sr){
  33. std::cout << "В "<<1900+i<<" кол-во осадков было на "<<(mas[i]-sr)<<" мл больше нормы.";
  34. }
  35. else{
  36. if(mas[i]<sr){
  37. std::cout << "В "<<1900+i<<" кол-во осадков было на "<<(mas[i]-sr)<<" мл меньше нормы.";
  38. }
  39. else{
  40. std::cout << "В "<<1900+i<<" кол-во осадков было в норме.";
  41.  
  42. }
  43.  
  44. }
  45. }
  46. }
  47.  
  48.  
  49. /*uses CRT;
  50. const n=50;
  51. var
  52. mas:array[1..n] of real;
  53. i:integer;
  54. sr:real;
  55.  
  56. Procedure input;
  57. Begin
  58.   sr:=0;
  59.   for i:=1 to n do
  60.   begin
  61.   clrscr;
  62.   writeln('Введите кол-во осадков в',i+1900,' году.');
  63.   readln(mas[i]);
  64.   sr:=sr+mas[i];
  65.   end;
  66.   sr:=sr/n;
  67. End;
  68.  
  69. Procedure proc;
  70. Begin
  71.   for i:=1 to n do
  72.   if mas[i]>sr then
  73.   writeln('В ',1900+i,' кол-во осадков было на ',(mas[i]-sr):0:2,'мл больше нормы.')
  74.   else if mas[i]<sr then
  75.   writeln('В ',1900+i,' кол-во осадков было на ',(-1*(mas[i]-sr)):3:2,'мл меньше нормы.')
  76.   else
  77.   writeln('В ',1900+i,' кол-во осадков было в норме.');
  78. End;
  79. BEGIN
  80.   input;
  81.   writeln('Среднее кол-во осадков=',sr:0:2,'.');
  82.   proc;
  83.   readln;
  84. END.*/
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:8: error: ‘n’ does not name a type
 const  n=50;
        ^
prog.cpp:8:12: error: ‘n’ was not declared in this scope
 double mas[n];
            ^
prog.cpp: In function ‘int main()’:
prog.cpp:15:7: error: ‘input’ was not declared in this scope
 input();
       ^
prog.cpp:17:6: error: ‘proc’ was not declared in this scope
 proc();
      ^
prog.cpp: In function ‘void input()’:
prog.cpp:22:18: error: ‘n’ was not declared in this scope
    for(int i=1;i<n;i++){
                  ^
prog.cpp:23:15: error: ‘clrscr’ was not declared in this scope
        clrscr();
               ^
prog.cpp:25:18: error: ‘mas’ was not declared in this scope
        std::cin>>mas[i];
                  ^~~
prog.cpp:28:9: error: ‘n’ was not declared in this scope
   sr=sr/n;
         ^
prog.cpp: In function ‘void proc()’:
prog.cpp:32:12: error: ‘mas’ was not declared in this scope
         if(mas[i]>sr){
            ^~~
stdout
Standard output is empty