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

×

# Code Review

 0 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 #include #include #include #include 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 1★vigonoid 168●2●6●14 accept rate: 0%

 0 @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". answered 28 Dec '13, 09:52 356●3●8●14 accept rate: 42% @sanjeev1779 Thanks! I got it :) (28 Dec '13, 09:55) vigonoid1★
 toggle preview community wiki:
Preview

### Follow this question

By Email:

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

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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