Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  stri.c
Language: C/C++
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
    int n,i,count=0;
    scanf("%d",&n);
    char s[n];
    for(int i=0;i<n;i++){
        scanf("%s",&s[i]);
    }
     int q;
        scanf("%d",&q);
        for(int j=0;j<q;j++){
          int k;
          scanf("%d",&k);
          int c=s[k];
          for(int i=0;i<k;i++){
            if(s[i]==s[k]){
                count++;
            }
        }
        printf("%d",count);
    }
    return 0;
}
          
Comments: