#4549
Să se genereze o matrice pătratică după un set de reguli ce simulează viața unei populații de viruși.
Conway
| Problema | Conway Game of Life | Operații I/O |
conway.in/conway.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #61837450 | Utilizator | |
| Fișier | conway_game_of_life.cpp | Dimensiune | 1.28 KB |
| Data încărcării | 11 Decembrie 2025, 17:45 | Scor/rezultat | Eroare de compilare |
conway_game_of_life.cpp:6:1: error: expected ',' or ';' before 'int' int n, a[100][100], g, i, j, b[100][100]; ^ conway_game_of_life.cpp: In function 'void citire()': conway_game_of_life.cpp:9:8: error: 'n' was not declared in this scope f>>n>>g; ^ conway_game_of_life.cpp:10:9: error: 'i' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:11:13: error: 'j' was not declared in this scope for(j=1; j<=n; j++) ^ conway_game_of_life.cpp:12:16: error: 'a' was not declared in this scope f>>a[i][j]; ^ conway_game_of_life.cpp: In function 'int nr_vecini(int, int)': conway_game_of_life.cpp:17:8: error: 'b' was not declared in this scope if(b[w-1][e-1]==1) ^ conway_game_of_life.cpp:19:8: error: 'b' was not declared in this scope if(b[w-1][e]==1) ^ conway_game_of_life.cpp:21:8: error: 'b' was not declared in this scope if(b[w-1][e+1]==1) ^ conway_game_of_life.cpp:23:8: error: 'b' was not declared in this scope if(b[w][e-1]==1) ^ conway_game_of_life.cpp:25:8: error: 'b' was not declared in this scope if(b[w][e+1]==1) ^ conway_game_of_life.cpp:27:8: error: 'b' was not declared in this scope if(b[w+1][e-1]==1) ^ conway_game_of_life.cpp:29:8: error: 'b' was not declared in this scope if(b[w+1][e]==1) ^ conway_game_of_life.cpp:31:8: error: 'b' was not declared in this scope if(b[w+1][e+1]==1) ^ conway_game_of_life.cpp: In function 'void game()': conway_game_of_life.cpp:37:9: error: 'i' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:37:17: error: 'n' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:38:13: error: 'j' was not declared in this scope for(j=1; j<=n; j++) ^ conway_game_of_life.cpp:39:13: error: 'b' was not declared in this scope b[i][j]=a[i][j]; ^ conway_game_of_life.cpp:39:21: error: 'a' was not declared in this scope b[i][j]=a[i][j]; ^ conway_game_of_life.cpp:40:9: error: 'i' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:40:17: error: 'n' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:42:13: error: 'j' was not declared in this scope for(j=1; j<=n; j++) ^ conway_game_of_life.cpp:44:16: error: 'b' was not declared in this scope if(b[i][j]==1) ^ conway_game_of_life.cpp:47:21: error: 'a' was not declared in this scope a[i][j]=0; ^ conway_game_of_life.cpp:49:16: error: 'b' was not declared in this scope if(b[i][j]==0 && nr_vecini(i, j)==3) ^ conway_game_of_life.cpp:50:17: error: 'a' was not declared in this scope a[i][j]=1; ^ conway_game_of_life.cpp: In function 'int main()': conway_game_of_life.cpp:57:19: error: no match for 'operator<=' (operand types are 'int' and 'std::ofstream {aka std::basic_ofstream<char>}') for(int u=1; u<=g; u++) ^ conway_game_of_life.cpp:57:19: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:239:5: note: template<class _T1, class _T2> constexpr bool std::operator<=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:239:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:315:5: note: template<class _Iterator> bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator<=(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:315:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:365:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator<=(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:365:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1067:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<=(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator<=(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1067:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1073:5: note: template<class _Iterator> bool std::operator<=(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator<=(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1073:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2643:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2643:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2655:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2655:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int' for(int u=1; u<=g; u++) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from conway_game_of_life.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2667:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<=(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2667:5: note: template argument deduction/substitution failed: conway_game_of_life.cpp:57:21: note: mismatched types 'const _CharT*' and 'int' for(int u=1; u<=g; u++) ^ conway_game_of_life.cpp:61:9: error: 'i' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:61:17: error: 'n' was not declared in this scope for(i=1; i<=n; i++) ^ conway_game_of_life.cpp:63:13: error: 'j' was not declared in this scope for(j=1; j<=n; j++) ^ conway_game_of_life.cpp:65:12: error: 'a' was not declared in this scope g<<a[i][j]<<" "; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Conway Game of Life face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.