Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Uva 272 - Tex Quotes

$
0
0

I wrote the code for the following problem but I keep on getting wrong answers its such a simple problem, but don't know where am I going wrong in my code, here is my code for reference

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>

using namespace std;

int main(){


        string inputString;

        while( getline( cin , inputString ) ){


                int nDoubleQuotes = 0;

                for(int i = 0 ; i < (int)inputString.length() ; ++i){

                    if( inputString[ i ] == '"' ){
                        ++nDoubleQuotes;

                        nDoubleQuotes = nDoubleQuotes%2;

                        if( nDoubleQuotes == 1 )
                            cout << "``";
                        else
                            cout << "''";
                    }

                    else
                        cout << inputString[ i ];
                }

                cout << '\n';

        }

        return 0;
}

kindly help me identify the anomaly in the code. here is the link to the problem -: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=607&page=show_problem&problem=208


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>