#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int T, i=1;
int count, length;
char str[81]={NULL};
cin>>T;
while(T--){
cin>>count>>str;
length=strlen(str);
cout << i << " ";
for(int j=count-1; j<=length-1; j++){
str[j]=str[j+1];
}
for(int j=0; j<=length-1; j++){
cout<<str[j];
}
cout<<endl;
i++;
}
system("pause");
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int T, i=1;
int count, length;
char str[81]={NULL};
cin>>T;
while(T--){
cin>>count>>str;
length=strlen(str);
cout << i << " ";
for(int j=count-1; j<=length-1; j++){
str[j]=str[j+1];
}
for(int j=0; j<=length-2; j++){
cout<<str[j];
}
cout<<endl;
i++;
}
system("pause");
return 0;
}
위 두 코드들은 거의 같지만 단 한 글자만 다르다. 위는 오답, 아래는 정답으로 인정되었다.
length-1의 경우, 보이지 않는 NULL 문자열 또한 같이 출력되기 때문에
화면 상으로는 보이지 않더라도 정답으로 인정하지 않는 것 같다.
'language > 알고리즘' 카테고리의 다른 글
WEEKLYCALENDAR (0) | 2016.07.31 |
---|---|
XOR 연산자를 이용한 Swap (0) | 2016.07.18 |
ENDIANS (0) | 2016.07.18 |
알고리즘: 효율, 분석 그리고 차수 (0) | 2016.07.10 |