結果

問題 No.2460 #強調#
ユーザー nekotinekoti
提出日時 2023-09-08 22:38:53
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 27,796 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 22:38:55
合計ジャッジ時間 1,238 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
//【find】
// 引数 :検索対象, 検索文字, n番目のhit(1はじまり)
// 戻り値:発見位置(0はじまり)
long long find(char* s, const char* find_string, int num/*1はじまり*/)
{
  long long res_idx=-1;
  
  long long find_len=strlen(find_string);
  if(0==find_len)return -1;
  char* p=s;
  while(1){
    p=strstr(p,find_string);
    res_idx++;
    if(NULL==p)break;
    //printf("%d,%u,%u\n",res_idx,p,s);
    if(num-1==res_idx)break;
    const char* p2=p+find_len;
    p+=find_len;
  }
  if(num-1!=res_idx)return -1;// 見つからなかった
  if(0<=p-s)return p-s;
  return -1;
}
int main(void)
{
  int scan;//scanf警告用
  int ans=0;
  int i, j;
  
  char s[101];//非配列用
  scan=scanf("%s",s);//非配列用
  int stidx, edidx;
  stidx = find(s,"#",1);
  edidx=find(&s[stidx+1], "#", 1);
  s[stidx+edidx+1]=0;
//  printf("%d %d\n", stidx,edidx);
  printf("%s",&s[stidx+1]);
  return 0;
}
0