結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-30 23:14:59 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 862 bytes |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 22,016 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-04 21:20:39 |
| 合計ジャッジ時間 | 1,284 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 3 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d",&t);
| ^~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%s",s[i]);
| ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[]){
int t,f;
char s[20][100001];
long len[20],i,c[20],j;
scanf("%d",&t);
for(i=0;i<t;i++){
getchar();
scanf("%s",s[i]);
len[i]=strlen(s[i]);
}
for(i=0;i<t;i++){
c[i]=-1;
}
for(i=0;i<t;i++){
f=0;
for(j=len[i]-1;j>=0;j--){
if(f==0 && '0'<=s[i][j] && s[i][j]<='9'){
if(s[i][j]=='9'){
f=1;
s[i][j]='0';
}else{
s[i][j]++;
break;
}
}
if(f==1){
if('0'<=s[i][j] && s[i][j]<'9'){
s[i][j]++;
break;
}
if(s[i][j]=='9') s[i][j]='0';
else{
c[i]=j;
break;
}
}
}
}
for(i=0;i<t;i++){
if(c[i]==-1) printf("%s\n",s[i]);
else{
for(j=0;j<c[i];j++){
printf("%c",s[i][j]);
}
printf("1");
for(j=c[i];j<len[i];j++){
printf("%c",s[i][j]);
}
printf("\n");
}
}
return 0;
}