游客 Signup | Login
中文 | En

2086 - 统计dollar符

编写程序,统计字符串中符号$的出现次数,输入要以EOF结束。

Input

字符文本

Output

$次数

Examples

Input

as$dfkjhkjkjdhf
asdfkj$lskdfj
werijweirjo$wie 

Output

3

Hint


#include <stdio.h>
int main(){
  FILE *p;
  .....
  //p=fopen("data.txt","r");
  p=stdin;
  .....
  //p=fopen("res.txt","w");
  p=stdout;
  ....
  return 0; 
}

Solution C

#include<stdio.h>
#include<string.h>
main()
{
	char ch[10000];
	int sum=0,k;
	while(scanf("%s",&ch)!=EOF)
	{
		for(int i=0;i<strlen(ch);i++)
		if(ch[i]=='$')
		sum++;
	}
	printf("%d\n",sum);
}

Solution C++

#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main() {
 	string a;
  int ans = 0;
  while(cin >> a) {
    for(int i = 0; i < (int)a.size(); i++)
      	if(a[i] == '$') ans++;
  }
  cout << ans << endl;
}

Hint


#include <stdio.h>
int main(){
  FILE *p;
  .....
  //p=fopen("data.txt","r");
  p=stdin;
  .....
  //p=fopen("res.txt","w");
  p=stdout;
  ....
  return 0; 
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题