Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct Sentence{
- int size;
- int histo[26];
- }Sentence;
- int main(int argc, char *argv[]) {
- char c;
- int count, n, m, i, j, k, *frequencies, *frequencies2;
- Sentence* letterCount;
- Sentence* letterCount2;
- scanf("%d", &n);
- letterCount = calloc(n, sizeof(Sentence));
- frequencies = calloc(n, sizeof(int));
- for(i=0; i < n; i++){
- count = 0;
- while((c = getchar()) && (c != '.')){
- if(c != ' '){
- if (c >= 'a' && c <= 'z' ) {
- letterCount[i].histo[c -'a']++;
- count++;
- letterCount[i].size = count; // size of the array
- }
- }
- }
- frequencies[i] = letterCount[i].size;
- }
- scanf("%d", &m);
- frequencies2 = calloc(m, sizeof(int));
- letterCount2 = calloc(n, sizeof(Sentence));
- for(i=0; i < m; i++){
- count = 0;
- while((c = getchar()) && (c != '.')){
- if(c != ' '){
- if (c >= 'a' && c <= 'z' ) {
- letterCount2[i].histo[c -'a']++;
- count++;
- letterCount2[i].size = count; // size of the array
- }
- }
- }
- frequencies2[i] = letterCount2[i].size;
- }
- for(i=0; i<m; i++){
- for(j=0; j<n; j++){
- if (frequencies2[i] == frequencies[j]){
- k=0;
- while((letterCount2[i].histo[k] == letterCount[j].histo[k]) && k<27){
- k++;
- }
- if((k = 27)){
- printf("%d ", j+1);
- }
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement