fork download
  1. // Lab 8, Working with structs
  2. // Programmer : Maiar Khattab
  3. // Editor(s) used : Code Blocks 13.12
  4. // Compiler(s) used : Code Blocks 13.12
  5.  
  6. #include<iostream>
  7. using std::cout;
  8. using std::endl;
  9.  
  10. #include<cstdlib>
  11.  
  12. //struct def
  13. struct tod
  14. {
  15. int hour;// the hr , 0-23
  16. int minute;// the min, 0-59
  17. int second;//the sec, 0-59
  18. char descr [32];//the description of the time of day
  19.  
  20. };
  21. //void printTod(const tod&);
  22. int main ()
  23. {
  24. cout << "Lab 8, Working With structs\n";
  25. cout << "Programmer: Maiar Khattab\n";
  26. cout << "Editor(s) used: Code Blocks 13.12\n";
  27. cout << "Compiler(s) used: Code Blocks 13.12\n";
  28. cout << "File: " << __FILE__ << endl;
  29. cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
  30.  
  31. tod theTime[] = {{12,0,0, "noon"},
  32. {0,0,0," midnight"},
  33. {6,00,00," supper "},
  34. {11,30,0,"bedtime"}};
  35.  
  36. for(int i; i <5; i++)
  37. {
  38. char descr [32];
  39. cout << theTime[i].descr << " is " << theTime[i].hour << ':'
  40. << theTime[i].minute << ":" << theTime[i].second << endl;
  41. }
  42. }
  43.  
  44.  
Success #stdin #stdout 0.01s 5476KB
stdin
 #include <bits/stdc++.h>

using namespace std;

struct datos{
int x, y, paso;
};
queue<datos>seguir
seguir now, next;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int M, N, mayor;

int main(){
cin >>M >>N;
char mapa[M+5][N+5];
int mp[M+5][N+5];

for(int i=0; i<M; i++){
 for(int j=0;j<N;j++){
  cin >> mapa[i][j];
 }
}

for(int i=0; i<M; i++){
 for(int j=0;j<N;j++){
  if(mapa[i][j]=='G'){
   next.x=i;
   next.y=j;
   next.paso=0;
   seguir.push(next);
   while(!seguir.empty()){
    now=seguir.front();
    seguir.pop();
    for(int k=0; k<4; k++){
     int oX=now.x+dx[k];
     int oY=now.y+dy[k];
     next.paso=now.paso+1;
     if(oX>=0&&oX<M&&oY>=0&&oY<N){
      if(mapa[oX][oY]=='.'&&mp[oX][oY]>next.paso){
       mp[oX][oY]=next.paso;
       next.x=oX;
       next.y=oY;
       seguir.push(next);
      }
     }
    }
   }
  }
 }
}

for(int i=0; i<M; i++){
 for(int j=0; j<N; j++){
  if(mp[i][j]>mayor){
   mayor=mp[i][j];
  }
 }
}

cout << mayor;
return 0;
}
stdout
Lab 8, Working With structs
Programmer: Maiar Khattab
Editor(s) used: Code Blocks 13.12
Compiler(s) used: Code Blocks 13.12
File: prog.cpp
Complied: May 27 2022 at 21:06:29

noon is 12:0:0
 midnight is 0:0:0
 supper  is 6:0:0
bedtime is 11:30:0
_�X ��qD is -2105444264:32764:-1385167872