結果

問題 No.207 世界のなんとか
ユーザー Maeda
提出日時 2025-03-03 11:19:45
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 510 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-03 11:19:57
合計ジャッジ時間 3,751 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:18:44: warning: passing argument 2 of ‘strstr’ makes pointer from integer without a cast [-Wint-conversion]
   18 |                 if( i/3 == 0 && strstr(str,'3') != NULL ){
      |                                            ^~~
      |                                            |
      |                                            int
In file included from main.c:2:
/usr/include/string.h:350:58: note: expected ‘const char *’ but argument is of type ‘int’
  350 | extern char *strstr (const char *__haystack, const char *__needle)
      |                                              ~~~~~~~~~~~~^~~~~~~~
main.c:21:32: warning: passing argument 2 of ‘strstr’ makes pointer from integer without a cast [-Wint-conversion]
   21 |                 if( strstr(str,'3') != NULL ){
      |                                ^~~
      |                                |
      |                                int
/usr/include/string.h:350:58: note: expected ‘const char *’ but argument is of type ‘int’
  350 | extern char *strstr (const char *__haystack, const char *__needle)
      |                                              ~~~~~~~~~~~~^~~~~~~~
main.c:18:33: warning: ‘strstr’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
   18 |                 if( i/3 == 0 && strstr(str,'3') != NULL ){
      |                                 ^~~~~~~~~~~~~~~
cc1: note: source object is likely at address zero
main.c:21:21: warning: ‘strstr’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
   21 |                 if( strstr(str,'3') != NULL ){
      |                     ^~~~~~~~~~~~~~~
cc1: note: source object is likely at address zero

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#define MAX_LEN (256)
void main(void){
	int a = 0 , b = 0;
	int inputA = scanf("%d",&a);
	if(inputA == 2){
		printf("Aの入力エラー\n");
	}
	int inputB = scanf("%d\n",&b);
	if(inputB == 2){
		printf("Bの入力エラー\n");
	}
	for(int i = a ; i <= b;i++){
		char str[MAX_LEN];
		snprintf(str, MAX_LEN, "%d", i);
		if( i/3 == 0 && strstr(str,'3') != NULL ){
			printf("%d\n",i);
		}
		if( strstr(str,'3') != NULL ){
			printf("%d\n",i);
		}
	}
}
0