結果

問題 No.547 未知の言語
ユーザー sasa
提出日時 2025-03-14 13:28:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 452 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-14 13:29:00
合計ジャッジ時間 5,644 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:22: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
    8 |         char *str1 = "test";
      |                      ^~~~~~
main.cpp:9:22: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
    9 |         char *str2 = "test";
      |                      ^~~~~~
main.cpp:22:46: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘int’ [-Wformat=]
   22 |                                 printf("%d\n%s\n%s\n",i + 1,*str1,*str2);
      |                                             ~^              ~~~~~
      |                                              |              |
      |                                              char*          int
      |                                             %d
main.cpp:22:50: warning: format ‘%s’ expects argument of type ‘char*’, but argument 4 has type ‘int’ [-Wformat=]
   22 |                                 printf("%d\n%s\n%s\n",i + 1,*str1,*str2);
      |                                                 ~^                ~~~~~
      |                                                  |                |
      |                                                  char*            int
      |                                                 %d
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&val);
      |         ~~~~~^~~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%s%s",str1,str2);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main(){
	int val = 0;
	scanf("%d",&val);
	
	char *str1 = "test";
	char *str2 = "test";
	for(int i = 0;i < val;i ++){
		scanf("%s%s",str1,str2);
		int len = 0;
		int len1 = strlen(str1);
		int len2 = strlen(str2);
		if(len1 > len2){
			len = len1;
		}else{
			len = len2;
		}
		for(int j = 0;j < len;j ++){
			if(str1[j] != str2[j]){
				printf("%d\n%s\n%s\n",i + 1,*str1,*str2);
				return 0;
			}
		}
	}
	
}
0