Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #define MN 31
  4. using namespace std;
  5. int N=0; //csucsok szama
  6. double A[MN][MN]; //csucsmatrix
  7.  
  8. void init(){
  9. for(int i=1; i<MN; i++){
  10. for(int j=1; j<MN; j++){
  11. A[i][j]=0;
  12. }
  13. }
  14. }
  15.  
  16. void beolvas(char *fnev){
  17. ifstream f;
  18. f.open(fnev);
  19. int a1, a2, a3;
  20. f>>a1>>a2>>a3;
  21. N=a1;
  22. switch(a2){
  23. case 1:{ //csucsmatrix
  24. for(int i=1; i<=N; i++){
  25. for(int j=1; j<=N; j++)f>>A[i][j];
  26. }
  27. break;
  28. }
  29. /** _____
  30. /\ \ \ \ \
  31. /OO\ \____\ \___ \
  32. /____\ \ \ \ \
  33. \ \ \_____ \_____
  34. **/
  35. case 2:{ //szomszedsagi lista
  36. if(a3>=3)break;
  37. for(int n=1; n<=N; n++){
  38. int cs, szn, sz;
  39. f>>cs>>szn;
  40. for(int i=1; i<=szn; i++){
  41. f>>sz;
  42. A[cs][sz]=1;
  43. }
  44. }
  45. break;
  46. }
  47. case 3:{
  48. int esz;
  49. f>>
  50. break;
  51. }
  52. }
  53. }
  54.  
  55. void kiir(){
  56. for(int i=1; i<=N; i++){
  57. for(int j=1; j<=N; j++){
  58. cout<<A[i][j]<<" ";
  59. }
  60. cout<<"\n";
  61. }
  62. }
  63.  
  64. int main()
  65. {
  66. init();
  67. beolvas("graf2.txt");
  68. kiir();
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement