aamir.coding's blog

By aamir.coding, 14 years ago, In English
/**************
Header Files
**************/
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
#include <string>
#include <iomanip>

using namespace std;

typedef vector<int> vi;

int main()
{
int row,col;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
string sentence;
vi  A;
vi  B;

for(int  i=0;i<rows;i++)
{  cin>>sentence;
  for (int j=0;j<cols;j++)
   {    Array[i][j]=sentence[j];
        if (Array[i][j]=='*')
        {  A.push_back(i);
           B.push_back(j);  }
   
   }
}
 
for(int i=A.at(0);i<A.at(A.size());i++)
{
  int max_B=0;
  int min_B=row-1;
  for ( unsigned l=0;l<B.size();l++)
    {
        if(max_B < B.at(l))
        max_B=B.at(l);
        if(min_B > B.at(l))
        min_B=B.at(l);
    }
 
  for (int j=min_B;j<max_B;j++)
   {   cout<<Array[i][j];                
   }
}

cin.get();
cin.ignore();
return 0;
}  


Full text and comments »

  • Vote: I like it
  • -20
  • Vote: I do not like it

By aamir.coding, 14 years ago, In English
I have written following program for problem 14 A(Letter):
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> vi;
int main()
{
int row,col;
char element;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
vi A;
vi B;
for(int i=0;i<row;i++)
{
  for (int j=0;j<col;j++)
   {   cin>>element; Array[i][j]=element;
    if (Array[i][j]=='*')
    {  A.push_back(i);
       B.push_back(j); }
   
   }
}

for(int i=A.at(0);i<A.at(A.size);i++)
{
  for (int j=B.at(0);j<B.at(B.size);j++)
   {   cout<<Array[i][j];
               
   }
}

return 0;
}  


I am getting the following compilation error which i am not able to fix....
can anybody help


Compilation Error:
In function ‘int main()’:
letter.cpp:73: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note:                 typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]

letter.cpp:75: error: no matching function for call to ‘std::vector<int, std::allocator<int> >::at(<unresolved overloaded function type>)’
/usr/include/c++/4.4/bits/stl_vector.h:650: note: candidates are: typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::reference std::vector<_Tp, _Alloc>::at(size_t) [with _Tp = int, _Alloc = std::allocator<int>]
/usr/include/c++/4.4/bits/stl_vector.h:668: note:                 typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp, _Alloc>::at(size_t) const [with _Tp = int, _Alloc = std::allocator<int>]

Thanks in advance...

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it