fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <locale>
  4.  
  5. using namespace std;
  6.  
  7. /* ********************************
  8.   * Лабораторная работа № 1 *
  9.   * Выполнил(а): ст. гр. ЗИ-123 *
  10.   * Иванов Андрей Петрович *
  11.   ******************************** */
  12.  
  13. int main() {
  14.  
  15. setlocale(LC_ALL,"Russian");
  16. string name, family, father, group="123";
  17. cout <<"Фамилия"<<endl;
  18. family="Иванов";
  19. cout <<"Имя"<<endl;
  20. name="Иван";
  21. cout <<"Отчество"<<endl;
  22. father="Иванович";
  23.  
  24. string text[4];
  25. text[1]="Лабораторная работа № 1";
  26. text[2]="Выполнил(а): ст. гр. ЗИ-";
  27. text[3]=family+" "+name+" "+father;
  28.  
  29. int maxLen;
  30. if (text[1].size>text[2].size) {
  31. maxLen=text[1].size;
  32. } else {
  33. maxLen=text[2].size;
  34. }
  35.  
  36. int starNum=10;
  37. string stars;
  38. for (int i=0;i<starNum;++i){
  39. stars+="*";
  40. }
  41.  
  42. text[0]=stars;
  43. text[4]=stars;
  44.  
  45. for (i;i<=4;++i){
  46. cout <<text[i]<<endl;
  47. }
  48.  
  49. return 0;
  50. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:30:14: error: invalid use of member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ (did you forget the ‘()’ ?)
  if (text[1].size>text[2].size) {
      ~~~~~~~~^~~~
prog.cpp:30:27: error: invalid use of member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ (did you forget the ‘()’ ?)
  if (text[1].size>text[2].size) {
                   ~~~~~~~~^~~~
prog.cpp:31:18: error: cannot convert ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size<char, std::char_traits<char>, std::allocator<char> >’ from type ‘std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept {aka long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept}’ to type ‘int’
   maxLen=text[1].size;
                  ^~~~
prog.cpp:33:18: error: cannot convert ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size<char, std::char_traits<char>, std::allocator<char> >’ from type ‘std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept {aka long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept}’ to type ‘int’
   maxLen=text[2].size;
                  ^~~~
prog.cpp:45:7: error: ‘i’ was not declared in this scope
  for (i;i<=4;++i){
       ^
stdout
Standard output is empty