結果

問題 No.436 ccw
ユーザー Haijinn
提出日時 2016-10-29 15:57:28
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 17:59:03
合計ジャッジ時間 1,424 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:11: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
   12 |         j=strlen(p);
      |           ^~~~~~
main.c:2:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:12:11: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
   12 |         j=strlen(p);
      |           ^~~~~~
main.c:12:11: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%s",p);
      |         ^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(void)
{
	char p[100000];
	int i=0;
	int j;
	int l=0;
	int u=0;
	int m;
	scanf("%s",p);
	j=strlen(p);
	for(i;i<j;i++){
		if(p[i]=='c'){
			l++;
		}
	}
	for(j;j-1>=0;j--){
		if(p[j]=='w'){
			
			u++;
		}
	}
	printf("%d%d",l,u);
	if(l<u||l==u){
		while(l>=2){
			l--;
			m++;
			
		}
	}else if(u>l){
		while(u>=1){
			u--;
			m++;
			
		}
	}
	
	printf("%d",m);
	return 0;
}
0