lundi 28 octobre 2019

How to parsing the input in c++?

I'm trying to parsing the input in c++!

  • 10 will be as n input!
  • Words will be string! Note: Some of them has space!
  • 10 16 -> 10 will be as n input again! the 16 will be as int e;
  • 0 2 to 9 7 should be followed by a and b.

example: all input on the left consider as a and on the right consider as b.

INPUT:


10
den
bou
alberquerque
santa fe
burl
mont
bratt
annap
washin
alexan
10 16
0 2
0 1
1 0
2 3
2 0
3 2
4 5
5 4
5 6
6 5
7 8
7 9
8 7
8 9
9 8
9 7
// Driver code 

int main() { 

  int n,e,a,b;

  cin>>n; 
  string str; 
   int t = n; 
   while (t--) 
   { 
       getline(cin, str); 

       // Keep reading a new line while there is 
       // a blank line 
       while (str.length()==0 ) 
           getline(cin, str); 

     //  cout << str << " : Testing" << endl; 
   } 





//    Graph g(n); 
//    g.addEdge(a, b); 




   return 0; 
} 

So far i have above code! but it's not complete! Can anyone help me to write the correct parsing code to read entire input correctly!

Thanks

Aucun commentaire:

Enregistrer un commentaire