summaryrefslogtreecommitdiff
path: root/numeri.cc
blob: 10be37fb81d8faaa8c817ae1491d9c40ef6e64cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <fstream>

using namespace std;

int main(void)
{
	fstream file;
	file.open("dati.dat");
	
	int a, b, c, seq = 0, tot = 0, num;
	char stringa[] = "112356812983";
	char l;
	while(true) 
	{
		cin >> a >> b >> c;
		if(a >= 0 && a <= 9 && b >= 0 && b <= 9 && c >= 0 && c <= 9){
			if(a != b && b != c && a != c) break;
		}
	}
	
	file << a << endl;
	file << b << endl;
	file << c << endl;
	file << stringa << endl;
	file.seekg(5, file.beg);
	
	while(!file.eof())
	{
		file.get(l);
		num = l - '0';
		if(seq == 0) {
			if(num == a) seq = 1;
		} else if(seq == 1) {
			if(num == b) seq = 2;
		} else if(seq == 2) {
			if(num == c) seq = 3;
		}
			
		if(seq == 3) { tot++; seq = 0; }	
	}
		
	cout << "\n" << tot;
	file.close();

	return 0;
}