You are not logged in. Please login at www.codechef.com to post your questions!

×

Code Review

I am trying to solve this problem on CodeForces. I came up with a solution and submitted it. However it is showing wrong answer on both testcases though it works completely fine on my system. Is anything wrong with the solution below? :

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;
int main(int argc,const char *argv[]){
    string userInput;
    int t;
    scanf("%d",&t);
    while(t--){
        cin >> userInput;
        if(userInput.length()<10){
        cout << userInput << "\n";
        }
        else{
        int n = userInput.length() - 2;
        cout << userInput[0] << n << userInput[n+1] << "\n";
        }
    }
    return 0;
    }
This question is marked "community wiki".

asked 28 Dec '13, 09:38

vigonoid's gravatar image

1★vigonoid
1682614
accept rate: 0%

edited 28 Dec '13, 09:38


@vigonoid , in the problem , it is mentioned that if the length strictly more than 10 characters , only then you have to change it. So, instead of "userInput.length()<10", use "userInput.length()<=10".

link

answered 28 Dec '13, 09:52

sanjeev1779's gravatar image

3★sanjeev1779
3563814
accept rate: 42%

@sanjeev1779 Thanks! I got it :)

(28 Dec '13, 09:55) vigonoid1★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,918
×688

question asked: 28 Dec '13, 09:38

question was seen: 797 times

last updated: 28 Dec '13, 09:55