Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <windows.h>
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- void print(int hr, int mn) {
- char mas[40][40] = {0};
- char rnd[40][81];
- double x, y;
- for (int i = 0; i < 360; i += 30) {
- x = sin(i*3.14 / 180.0)*15.0;
- y = cos(i*3.14 / 180.0)*15.0;
- x += 20.5;
- y += 20.5;
- mas[(int)x][(int)y] = 1;
- }
- hr *= 360 / 12;
- hr += mn * 360 / 60 / 12;
- hr -= 90;
- for (double len = 0; len <= 8.0; len += 0.5) {
- x = sin(hr*3.14 / 180.0)*len;
- y = cos(hr*3.14 / 180.0)*len;
- x += 20.5;
- y += 20.5;
- mas[(int)x][(int)y] = 2;
- }
- mn *= 360 / 60;
- mn -= 90;
- for (double len = 0; len <= 13.0; len += 0.5) {
- x = sin(mn*3.14 / 180.0)*len;
- y = cos(mn*3.14 / 180.0)*len;
- x += 20.5;
- y += 20.5;
- mas[(int)x][(int)y] = 2;
- }
- for (int i = 0; i < 40; i++) {
- for (int j = 0; j < 40; j++) {
- if (mas[i][j] == 1) {
- rnd[i][j * 2] = '-';
- rnd[i][j * 2 + 1] = '-';
- }
- else if (mas[i][j] == 2) {
- rnd[i][j * 2] = '*';
- rnd[i][j * 2 + 1] = '*';
- }
- else {
- rnd[i][j * 2] = ' ';
- rnd[i][j * 2 + 1] = ' ';
- }
- }
- rnd[i][80] = '\n';
- }
- rnd[39][80] = '\0';
- system("cls");
- for (int i = 0; i < 40; i++) {
- puts(rnd);
- }
- }
- double abs_dbl(double a) {
- if (a < 0)
- return -a;
- return a;
- }
- //4
- //-------------------------------------------------------
- void m_strcat(char* s, char* t, int n) {
- int i = 0;
- int j = 0;
- while (s[i] != '\0') {
- i++;
- }
- while (t[j] != '\0' && j < n) {
- s[i] = t[j];
- i++;
- j++;
- }
- s[i] = '\0';
- }
- //5
- //-------------------------------------------------------
- int multiply(int a, int b) {
- return multiply_r(a, b, 0);
- }
- int multiply_r(int a, int n, int ans) {
- if (n)
- return multiply_r(a, --n, ans + a);
- return ans;
- }
- int main() {
- int h = 0;
- int m = 0;
- int m_count = 0;
- printf("Hour: ");
- scanf("%i", &h);
- printf("Min: ");
- scanf("%i", &m);
- if (h >= 0 && h < 12 && m >= 0 && m < 60) {
- print(h, m);
- _getch();
- double h_ang = h * 360.0 / 12.0;
- h_ang += m * 360.0 / 12.0 / 60.0;
- double m_ang = m * 360.0 / 60.0;
- while (abs_dbl(h_ang - m_ang) > 360.0 / 60.0) {
- m_count++;
- m++;
- if (m >= 60) {
- h++;
- m = 0;
- }
- if (h >= 12)
- {
- h = 0;
- }
- print(h, m);
- h_ang = h * 360.0 / 12.0;
- h_ang += m * 360.0 / 12.0 / 60.0;
- m_ang = m * 360.0 / 60.0;
- //printf("\nAngle: %.2f", abs_dbl(h_ang - m_ang));
- Sleep(150);
- }
- printf("%i hour %i minutes passed\n", m_count / 60, m_count % 60);
- }
- else {
- printf("ERROR\n");
- }
- _getch();
- system("cls");
- char s1[256], s2[256];
- int n;
- printf("String 1: ");
- scanf("%s", &s1);
- printf("String 2: ");
- scanf("%s", &s2);
- printf("N: ");
- scanf("%i", &n);
- m_strcat(s1, s2, n);
- printf("String result: %s\n", s1);
- _getch();
- system("cls");
- int a, b;
- printf("A: ");
- scanf("%i", &a);
- printf("B: ");
- scanf("%i", &b);
- printf("%i * %i = %i\n", a, b, multiply(a, b));
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement