#1678
modifMat
Se citeşte din fişierul de intrare o matrice pătratică A
cu n
linii şi n
coloane conţinând numere naturale. Scrieţi un program care modifică matricea A
în modul următor:
I. interschimbă elementele matricei din triunghiul superior cu cele din triunghiul inferior al matricei
II. după aceea interschimbă elementele superprime distincte, care apar în triunghiul din dreapta cu cel din triunghiul din stânga al matricei (ambele elemente trebuie să fie superprime);
Admitere Mate-Info UBB, septembrie 2014
Problema | modifMat | Operații I/O |
![]() matrice.in /matrice.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #50920558 | Utilizator | |
Fișier | modifmat.cpp | Dimensiune | 1.27 KB |
Data încărcării | 14 Mai 2024, 12:02 | Scor / rezultat | Eroare de compilare |
modifmat.cpp: In function 'bool Prim(int)': modifmat.cpp:10:9: error: 'd' was not declared in this scope for(d=2; d*d<=n; d++) ^ modifmat.cpp: In function 'bool SuperPrim(int)': modifmat.cpp:35:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ modifmat.cpp: In function 'int main()': modifmat.cpp:47:31: error: no matching function for call to 'swap(int&, int [51])' swap(a[i][j],a[n+1-i]); ^ modifmat.cpp:47:31: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, from /usr/include/c++/4.8/bits/stl_algobase.h:64, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from modifmat.cpp:1: /usr/include/c++/4.8/bits/move.h:166:5: note: template<class _Tp> void std::swap(_Tp&, _Tp&) swap(_Tp& __a, _Tp& __b) ^ /usr/include/c++/4.8/bits/move.h:166:5: note: template argument deduction/substitution failed: modifmat.cpp:47:31: note: deduced conflicting types for parameter '_Tp' ('int' and 'int [51]') swap(a[i][j],a[n+1-i]); ^ In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0, from /usr/include/c++/4.8/bits/stl_algobase.h:64, 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/istream:38, from /usr/include/c++/4.8/fstream:38, from modifmat.cpp:1: /usr/include/c++/4.8/bits/move.h:185:5: note: template<class _Tp, unsigned int _Nm> void std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm]) swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) ^ /usr/include/c++/4.8/bits/move.h:185:5: note: template argument deduction/substitution failed: modifmat.cpp:47:31: note: mismatched types '_Tp [_Nm]' and 'int' swap(a[i][j],a[n+1-i]); ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from modifmat.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:254:5: note: template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&) swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:254:5: note: template argument deduction/substitution failed: modifmat.cpp:47:31: note: mismatched types 'std::pair<_T1, _T2>' and 'int' swap(a[i][j],a[n+1-i]); ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from modifmat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2717:5: note: template<class _CharT, class _Traits, class _Alloc> void std::swap(std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&) swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2717:5: note: template argument deduction/substitution failed: modifmat.cpp:47:31: note: mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'int' swap(a[i][j],a[n+1-i]); ^ modifmat.cpp:53:13: warning: unused variable 'x' [-Wunused-variable] int x=a[i][j]; ^ modifmat.cpp:54:13: warning: unused variable 'y' [-Wunused-variable] int y=a[i][n+1-j]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema modifMat 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ă.