Codeforces 71a solution in c ||Codeforces 71a way too long words C, C++
Codeforces 71a Solution ||way too long words Code forces solution
Step1: Learning the Problem
The question is asking you to abbreviate words that are “so lengthy. A word has been fixed to 10 characters. Anyway, the process for abbreviating it is to swap out some middle-excerpt with a number that dentotes exactly how many letters in between its 1 and last character. So “internationalization” would be i18n (i + 18 letters + n). You leave the word as is if it has 10 characters or less.
Step 2: Input the Words
These words will be given to you. Check the length of each word. If 10 or less, just Print it as is
Step 3: Shorten Long Words
Take 1st letter count the number of characters between first and last, then add Last Letter. (for more than 10 letters) Such as l10n for localization.
Step 4: Output the Results
Once all the words are processed return each in its shortened or as is state.
And that is how the code for 71A problem in Codeforces can be easily implemented!
Codeforces -71A. Way Too Long Words question link
Understanding the issue
The unsettling message in “Way Too Long Words” is simple. It necessitates that we reduce terms that may be overly long due to specific circumstances. The entry consists of an integer ‘n’ followed by ‘n’ words. If the period of a word exceeds 10 characters, we want to update it with a new string that comprises the initial letter, the number of letters between the first and last letters (different), and the last letter.
71a Codeforce Solution in C++
#include<iostream> #include<string> using namespace std; int main() { int n; string s; cin>>n; for (int i=0;i>s; int b=s.length(); if(b>10) { cout<<s[0]<<b-2<<s[b-2]<<endl;//Way too long words solution } else { cout<<s<<endl; } } return 0; }
Codeforces 71a solution in C
#include<stdio.h>
#include<string.h>
int main() {
int n;
char s[100]; // Assuming max length of the string is 100
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s", s);
int b = strlen(s);
if (b > 10) {
printf("%c%d%c\n", s[0], b-2, s[b-1]); // Way too long words Codeforces solution in C
} else {
printf("%s\n", s);
}
}
return 0;
}
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your article helped me a lot, is there any more related content? Thanks!
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.