Cod sursa(job #1814108)

Utilizator rosuflaRosu Flaviu rosufla Data 23 noiembrie 2016 17:42:25
Problema Potrivirea sirurilor Scor 14
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

ifstream f("strmatch.in");
ofstream g("strmatch.out");

int main(){
	string a, b;
	getline(f,a);
	getline(f,b);

	unsigned int i = 0, j = 0;
	int count = 0;

	while (b[i] != '\0' && a[j] != '\0') {
		while (a[j] != '\0' && b[i] != '\0' && b[i] == a[j]) {
			i++;
			j++;
		}
		if (j == (a.length()))
			count++;
		i = i - j + 1;
		j = 0;
	}

	g << count << "\n";

	f.close();
	g.close();
    return 0;
}