結果

問題 No.2460 #強調#
コンテスト
ユーザー nekoti
提出日時 2023-09-08 22:38:53
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 965 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 206 ms
コンパイル使用メモリ 38,464 KB
最終ジャッジ日時 2026-02-22 11:14:33
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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