1 条题解
-
0
C :
#include <stdio.h> int main(int argc, const char * argv[]) { // insert code here... char str[20]; char ch ; char c; int i = 0; int count = 0; gets(str); scanf("%c",&ch); c = str[i]; while(c != '\0') { if(ch == c) { count++; printf("%d ",i); } c = str[++i]; } printf("\n%d",count); return 0; }
C++ :
#include<iostream> #include<string> using namespace std; int main() { string s; char c; getline(cin,s); cin>>c; int sum=0; for(int i=0;i<s.length();++i) { if(s[i]==c) { cout<<i<<" "; sum++; } } cout<<endl; cout<<sum; return 0; }
- 1
信息
- ID
- 3271
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者