1 条题解

  • 0
    @ 2024-12-24 9:59:28

    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);
    }
    

    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;
    }
    
    • 1

    信息

    ID
    1548
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者