結果

問題 No.2707 Bag of Words Encryption
ユーザー Maeda
提出日時 2025-03-19 09:37:28
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-19 09:37:30
合計ジャッジ時間 1,860 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[1000000]’ [-Wformat=]
    8 |         scanf("%s",&str);
      |                ~^  ~~~~
      |                 |  |
      |                 |  char (*)[1000000]
      |                 char *
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%s",&str);
      |         ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void main(void){
	const int englishNumber = 26;
	int n = 0;
	scanf("%d",&n);
	char str[1000000] = "a";
	scanf("%s",&str);
	for(int i = 0 ; i < englishNumber ; i++){
		int count = 0;
		for( int j = 0 ; j < n ; j++ ){
			if( i == str[j] - 'A'){
				count++;
			}
		}
		printf("%d",count);
	}
	
}
0