1 solutions
-
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
Information
- ID
- 18066
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By