fork download
  1. #include<iostream>
  2. #include<string>
  3. #include<stdio.h>
  4. #include<math.h>
  5. float max(float *f, int n)
  6. {
  7. float m=f[0];
  8. for(int i=0;i<n;i++)
  9. {
  10. if(f[i]>m)m=f[i];
  11. }
  12. return m;
  13. }
  14. float moy(float f, int m)
  15. {
  16. flaot m=0;
  17. for(int i=0;i<n;i++)m+=f[i];
  18. return m/n;
  19. }
  20. using namespace std;
  21.  
  22. int main()
  23. {
  24. int n, i, j;
  25. cin>>n;
  26. while(n!=0)
  27. {
  28. string s;
  29. string u[50];
  30. char t[25];
  31. float f[25];
  32.  
  33. flaot dis[n];
  34. float x[n], y[n];
  35. for(int o=0;o<n;o++)
  36. {
  37. cin>>x[o]>>y[o];
  38. getline(s,cin);
  39. int m=s.size();
  40. j=0;
  41. float al=0, d=0;
  42. for(i=0;i<m;i++)
  43. {
  44. if(s[i]==' ')
  45. {
  46. j++;
  47. }
  48. else
  49. {
  50. t[j][i]=s[i];
  51. }
  52. }
  53. for(i=0;i<j;i+=2)
  54. {
  55. switch(t[i])
  56. {
  57. case "start" :
  58. {
  59. al= atof( t[i+1].c_str() );
  60. break;
  61. }
  62. case "walk" :
  63. {
  64. d[o]+=atof( t[i+1].c_str() );
  65. x[o]+=atof( t[i+1].c_str() )*cos(al);
  66. y[o]+=atof( t[i+1].c_str() )*sin(al);
  67. break;
  68. }
  69. case "turn" :
  70. {
  71. al=atof( t[i+1].c_str() );
  72. break;
  73. }
  74. }
  75.  
  76. }
  77. printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
  78. }
  79. cin>>n;
  80. }
  81. }
  82.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
3
87.342 34.30 start 0 walk 10.0
2.6762 75.2811 start -45.0 walk 40 turn 40.0 walk 60
58.518 93.508 start 270 walk 50 turn 90 walk 40 turn 13 walk 5
2
30 40 start 90 walk 5
40 50 start 180 walk 10 turn 90 walk 5
0
compilation info
prog.cpp: In function ‘float moy(float, int)’:
prog.cpp:16:5: error: ‘flaot’ was not declared in this scope
     flaot m=0;
     ^~~~~
prog.cpp:17:19: error: ‘n’ was not declared in this scope
     for(int i=0;i<n;i++)m+=f[i];
                   ^
prog.cpp:17:31: error: invalid types ‘float[int]’ for array subscript
     for(int i=0;i<n;i++)m+=f[i];
                               ^
prog.cpp:18:14: error: ‘n’ was not declared in this scope
     return m/n;
              ^
prog.cpp: In function ‘int main()’:
prog.cpp:33:9: error: ‘flaot’ was not declared in this scope
         flaot dis[n];
         ^~~~~
prog.cpp:38:26: error: no matching function for call to ‘getline(std::__cxx11::string&, std::istream&)’
             getline(s,cin);
                          ^
In file included from /usr/include/stdio.h:935:0,
                 from /usr/include/c++/6/cstdio:42,
                 from /usr/include/c++/6/ext/string_conversions.h:43,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio.h:115:1: note: candidate: __ssize_t getline(char**, size_t*, FILE*)
 getline (char **__lineptr, size_t *__n, FILE *__stream)
 ^~~~~~~
/usr/include/x86_64-linux-gnu/bits/stdio.h:115:1: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.h:5395:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     getline(basic_istream<_CharT, _Traits>&& __is,
     ^~~~~~~
/usr/include/c++/6/bits/basic_string.h:5395:5: note:   template argument deduction/substitution failed:
prog.cpp:38:26: note:   ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
             getline(s,cin);
                          ^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.h:5388:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
     getline(basic_istream<_CharT, _Traits>&& __is,
     ^~~~~~~
/usr/include/c++/6/bits/basic_string.h:5388:5: note:   template argument deduction/substitution failed:
prog.cpp:38:26: note:   ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
             getline(s,cin);
                          ^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.h:5380:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     getline(basic_istream<_CharT, _Traits>& __is,
     ^~~~~~~
/usr/include/c++/6/bits/basic_string.h:5380:5: note:   template argument deduction/substitution failed:
prog.cpp:38:26: note:   ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
             getline(s,cin);
                          ^
In file included from /usr/include/c++/6/string:53:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.tcc:1509:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
     getline(basic_istream<_CharT, _Traits>& __in,
     ^~~~~~~
/usr/include/c++/6/bits/basic_string.tcc:1509:5: note:   template argument deduction/substitution failed:
prog.cpp:38:26: note:   ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
             getline(s,cin);
                          ^
prog.cpp:50:27: error: invalid types ‘char[int]’ for array subscript
                     t[j][i]=s[i];
                           ^
prog.cpp:57:26: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]
                     case "start" :
                          ^~~~~~~
prog.cpp:57:26: error: ‘(int)((const char*)"start")’ is not a constant expression
prog.cpp:59:42: error: request for member ‘c_str’ in ‘t[(i + 1)]’, which is of non-class type ‘char’
                         al= atof( t[i+1].c_str() );
                                          ^~~~~
prog.cpp:62:26: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]
                     case "walk" :
                          ^~~~~~
prog.cpp:62:26: error: ‘(int)((const char*)"walk")’ is not a constant expression
prog.cpp:64:28: error: invalid types ‘float[int]’ for array subscript
                         d[o]+=atof( t[i+1].c_str() );
                            ^
prog.cpp:64:44: error: request for member ‘c_str’ in ‘t[(i + 1)]’, which is of non-class type ‘char’
                         d[o]+=atof( t[i+1].c_str() );
                                            ^~~~~
prog.cpp:65:44: error: request for member ‘c_str’ in ‘t[(i + 1)]’, which is of non-class type ‘char’
                         x[o]+=atof( t[i+1].c_str() )*cos(al);
                                            ^~~~~
prog.cpp:66:44: error: request for member ‘c_str’ in ‘t[(i + 1)]’, which is of non-class type ‘char’
                         y[o]+=atof( t[i+1].c_str() )*sin(al);
                                            ^~~~~
prog.cpp:69:26: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]
                     case "turn" :
                          ^~~~~~
prog.cpp:69:26: error: ‘(int)((const char*)"turn")’ is not a constant expression
prog.cpp:71:41: error: request for member ‘c_str’ in ‘t[(i + 1)]’, which is of non-class type ‘char’
                         al=atof( t[i+1].c_str() );
                                         ^~~~~
prog.cpp:77:46: error: cannot convert ‘float*’ to ‘float’ for argument ‘1’ to ‘float moy(float, int)’
             printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
                                              ^
prog.cpp:77:55: error: cannot convert ‘float*’ to ‘float’ for argument ‘1’ to ‘float moy(float, int)’
             printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
                                                       ^
prog.cpp:77:64: error: no matching function for call to ‘max(float&, int&)’
             printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
                                                                ^
prog.cpp:5:7: note: candidate: float max(float*, int)
 float max(float *f, int n)
       ^~~
prog.cpp:5:7: note:   no known conversion for argument 1 from ‘float’ to ‘float*’
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
prog.cpp:77:64: note:   deduced conflicting types for parameter ‘const _Tp’ (‘float’ and ‘int’)
             printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
                                                                ^
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
prog.cpp:77:64: note:   deduced conflicting types for parameter ‘const _Tp’ (‘float’ and ‘int’)
             printf("%.4f %.4f %.5f\n",moy(x,n),moy(x,n),max(d,n));
                                                                ^
stdout
Standard output is empty