Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×
Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Error gives in codeforces compiler but in vscode gives answer in same condition

Правка en1, от Codersaurus, 2022-11-23 19:14:24

Hello friends, I'm newbie to codeforces and these problems by using c language.and When I submit my code It always says that "Wrong answer on test 1". But when I run my code on vscode succesfully and it gives correct output in A. Helpful Maths problem. And this is my code. It's little bit lenthy. But it works correctly.I don't why i'm getting that error. This link helps you to go my answer ~~~~~ #include <stdio.h> #include <string.h>       int main(void){ char mystring[101]; int a,b,c; scanf("%s",mystring); for(int i = 0; i < strlen(mystring);i++){ if (mystring[i]== '1'){ a++; } else if (mystring[i]== '2'){ b++; } else if (mystring[i]== '3'){ c++; }
} //printf("%d\n %d\n %d",a,b,c); for(int j = 0; j < strlen(mystring);){ if (j < a){ printf("%c",'1');
} else if ( j < a + b && j >= a){ printf("%c",'2'); } else if ( j < a + b + c && j >= b){ printf("%c",'3'); } j++; if ( j <= a + b + c -1) printf("%c",'+');   } printf("\n");
    } ~~~~~

Теги #greedy, #strings, #sortings, #implementation, #newbie

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Codersaurus 2022-11-23 19:32:20 1018
en1 Английский Codersaurus 2022-11-23 19:14:24 1554 Initial revision (published)