NeekT's blog

By NeekT, history, 3 years ago, In English

I was attempting problem 118A (https://codeforces.com/problemset/problem/118/A) and I got it wrong the first time. I'd like some help to figure out what went awry (my submission: https://codeforces.com/contest/118/submission/107014817) but my major issue is another one. I was looking at some other solutions to get clues about my own mistakes, and I found this submission as an accepted answer:

#include<stdio.h>
#include<string.h>
main()
{
char a[101];int i;
gets(a);
strlwr(a);
for(i=0;a[i]!='\0';i++)
{if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='y')
;else
printf(".%c",a[i]);}
}

The instructions for the problem are quite clear: "The program's input is exactly one string, it should return the output as a single string," but in this solution the answer is not a single string. A single string should be printed out with something like "%s",string. What am I missing here?

  • Vote: I like it
  • -27
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Checkers do not analyze your code. Printing a single string means printing a list of characters without any extra characters. That means you should not print — "The answer is: aburb", or anything extra besides the result. Thus, printing character by character is just as correct as building a string and then printing it.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

doesn't your solution also print out the string character by character?