結果

問題 No.495 (^^*) Easy
ユーザー dai11dai11
提出日時 2017-07-05 09:52:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 157,908 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-15 18:09:11
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:20:17: warning: format ‘%s’ expects argument of type ‘char*’, but argument 2 has type ‘char (*)[100000]’ [-Wformat=]
   20 |         scanf("%s",&S); //入力する文字列
      |                ~^  ~~
      |                 |  |
      |                 |  char (*)[100000]
      |                 char*
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%s",&S); //入力する文字列
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char **argv)
{
	int i; //ループカウンタ
	int t; //文字列を数値として格納
	int k; //左向きのカウンタ
	int y; //右向きのカウンタ
	char S[100000]; //格納する文字列
	
	//初期化
	i = 0;
	t = 0;
	k = 0;
	y = 0;
	
	 
	scanf("%s",&S); //入力する文字列
	t = strlen(S); //文字列を数値として置き換える
	
	for(i = 1;i<=t;i=i+5) //文字列の数だけループする
	  {
	    if('^' == S[i]) //左向きの条件
	      {
	        k++;
	      }
	    else if('*' == S[i]) //右向きの条件
	      {
	        y++;
	      }
	  }
	printf("%d %d\n",k,y);
	return 0;
}
0