summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-01-18 22:00:23 +0100
committerGitHub <noreply@github.com>2017-01-18 22:00:23 +0100
commitccaa37375635f87a8d9dc7fb9f7435f2049cbe12 (patch)
treecf351e83700937163fc81bf429a0b99106ae0e28
parent73c71fb66429034a8ecf6a9a04e89088d74a9b3f (diff)
corso 18/1/17
-rw-r--r--numeri.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/numeri.cc b/numeri.cc
new file mode 100644
index 0000000..10be37f
--- /dev/null
+++ b/numeri.cc
@@ -0,0 +1,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;
+}