Cod sursa(job #1170947)

Utilizator andreifirstCioara Andrei Ioan andreifirst Data 14 aprilie 2014 21:48:51
Problema Potrivirea sirurilor Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>

#define e '\n'

using namespace std;

#define FILE "strmatch"

#define INF 1023456789
#define ll long long

#ifdef FILE
ifstream f(string (string(FILE) + ".in").c_str());
ofstream g(string (string(FILE) + ".out").c_str());
#endif
#ifndef FILE
#define f cin
#define g cout
#endif

string sach, needle;
vector<int> rez;

int i, j, n, m, t;

int main() {

	f >> needle;
	f >> sach;

	for(i=0; i<sach.size(); i++) {
		if (sach[i] == needle[0]) {
			for (j=0; j<needle.size(); j++) {
				if (sach[i+j] != needle[j]) {
					break;
				}
			}
			if (j == needle.size()) {
				rez.push_back(i);
			}
		}
	}


	g << rez.size() << e;
	for (i=0; i<rez.size(); i++) {
		g << rez[i] << " ";
	}

	return 0;

}