Cod sursa(job #215879)

Utilizator cvicentiuCiorbaru Vicentiu Marian cvicentiu Data 21 octombrie 2008 17:51:09
Problema Subsir Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <string>
#include <fstream>
#include <iostream>

using namespace std;

char s1[501],s2[501];
int k,v[501],cate;

int citire() {
    int i;
    ifstream f ("subsir.in");
    f.getline(s1,501);
    f.getline(s2,501);
    f.close();
}

int scriere() {
    int i;
    ofstream f ("subsir.out");
    f<<cate;
}

void pdin(){
    int max;
    int lun;
    if (strlen(s1)>strlen(s2)) {
       max = strlen(s1);
       }else {max = strlen(s2);}
       
    if (s1[0]=s2[0]) {v[0]=1;} else {v[0]=0;}
    
    for (k=1; k<max; k++){
        if (s1[k]=s2[k]) {
           v[k]=v[k-1]+1;
           } else {v[k]=0;}
    }
    lun=0;
    cate=0;
    for (k=0; k<max; k++){
        if (v[k]==lun && v[k]!=0) {
                      cate=cate+1;
                      }
        if (v[k]>lun) {cate=1;
                       lun=v[k];
                       }
        }
}             
    

int main(){
citire();
pdin();
scriere();



}