Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void average700() {
- int n = 0;
- int step = 0;
- double aver = 0;
- double summ = 0;
- do {
- n++;
- int k = 2;
- bool is_simple = true;
- while (k < n) {
- if ((n % k) == 0) {
- is_simple = false;
- break;
- }
- k++;
- }
- if (is_simple) {
- step++;
- summ += n;
- aver = summ / step;
- cout << aver << endl;
- }
- } while (aver < 700);
- /*
- while (aver < 700) {
- step++;
- n++;
- summ += n;
- aver = summ / step;
- cout << aver << endl;
- }
- */
- }
- void calc_clock() {
- const int n = 12;
- int num_bam = 0;
- for (int k = 1; k <= n; k++) {
- num_bam += k;
- }
- cout << num_bam << endl;
- }
- void test_fibbo() {
- int Fn_1 = 1; // F1
- int Fn_2 = 0; // F0
- int Fn;
- for (int n = 2; n < 20; n++) {
- Fn = Fn_2 + Fn_1;
- cout << Fn << endl;
- Fn_2 = Fn_1;
- Fn_1 = Fn;
- }
- }
- void test_lucky() {
- int val, a1, a2, a3, a4, a5, a6;
- int num = 0;
- for (int n = 1; n < 999999; n++) {
- val = n;
- a6 = val % 10;
- val /= 10;
- a5 = val % 10;
- val /= 10;
- a4 = val % 10;
- val /= 10;
- a3 = val % 10;
- val /= 10;
- a2 = val % 10;
- val /= 10;
- a1 = val % 10;
- val /= 10;
- if ((a1 + a2 + a3) == (a4 + a5 + a6)) {
- cout << n << " ";
- num++;
- continue;
- }
- if ((a1 == a2 == a3) && (a4 == a5 == a6)) {
- cout << n << " ";
- num++;
- continue;
- }
- if ((10 * a1 + a2) == (10 * a3 + a4) &&
- (10 * a1 + a2) == (10 * a5 + a6)) {
- cout << n << " ";
- num++;
- continue;
- }
- }
- cout << endl << " lucky" << num << endl;
- }
- int main() {
- //average700();
- /*
- int n = 0;
- while (n < 777) {
- n++;
- if (n > 100 && n < 777)
- continue;
- cout << n << " ";
- }
- */
- //test_fibbo();
- //calc_clock();
- test_lucky();
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement