├── 10.2 ├── task3.c ├── task4.c ├── task5.c ├── task2.c ├── task1.c ├── task7.c ├── task6.c └── task8.c ├── 10.1 ├── task1.c ├── task2.c ├── task9.c ├── task10.c ├── task3 ├── task4.c ├── task6 ├── task7 ├── task5 └── task8 ├── 10.3 ├── task1.c ├── task5.c ├── task6.c ├── task3.c ├── task2.c ├── task4.c ├── task8.c ├── task11.c ├── task7.c ├── task9.c ├── task12.c └── task10.c ├── 3.1 ├── task3 ├── task1 ├── task5 ├── task4 └── task2 ├── 4.1 ├── task6 ├── task2 ├── task5 ├── task7 ├── task3 ├── task4 └── task1 ├── 5.1 ├── task10 ├── task3 ├── task1 ├── task7 ├── task2 ├── task9 ├── task5 ├── task14 ├── task8 ├── task4 ├── task6 ├── task12 ├── task11 └── task13 ├── 5.2 ├── task10 ├── task13 ├── task5 ├── task6 ├── task9 ├── task14 ├── task1 ├── task2 ├── task7 ├── task8 ├── task11 ├── task12 ├── task4 └── task3 ├── 5.3 ├── task7 ├── task8 ├── task4 ├── task1 ├── task3 ├── task9 ├── task13 ├── task14 ├── task11 ├── task12 ├── task2 ├── task5 ├── task6 └── task10 ├── 6.2 ├── task1 └── task2 ├── 6.3 ├── task1 ├── task3 ├── task6 ├── task7 ├── task2 ├── task5 ├── task9 ├── task4 ├── task8 └── task10 ├── 9.1 ├── task1 ├── task2 ├── task5 ├── task6 ├── task4 └── task3 ├── 1.1 ├── task3 ├── task2 ├── task4 └── task1.c ├── 3.2 ├── task2 ├── task3 └── task1 ├── 4.2 ├── task2 ├── task5 ├── task4 ├── task1 └── task3 ├── 7.1 ├── task1 ├── task4 ├── task5 ├── task6 ├── task2 ├── task7 ├── task8 ├── task9 ├── task3 ├── task11 └── task10 ├── 7.2 ├── task1 ├── task11 ├── task2 ├── task3 ├── task6 ├── task8 ├── task7 ├── task4 ├── task9 ├── task10 ├── task12 ├── task14 ├── task5 └── task13 ├── 9.3 ├── task2 ├── task1 ├── task4 ├── task6 ├── task3 ├── task5 ├── task7 └── task8 ├── 7.3 ├── task1 ├── task2 ├── task9 ├── task8 ├── task7 ├── task4 ├── task3 ├── task5 └── task6 ├── 4.4 ├── task1 ├── task2 └── task3 ├── 4.3 ├── task2 └── task1 ├── 8.1 ├── task1 ├── task6 ├── task2 ├── task3 ├── task4 ├── task5 ├── task8 ├── task7 └── task9 ├── 6.1 ├── task3 ├── task9 ├── task8 ├── task1 ├── task2 ├── task5 ├── task4 ├── task6 └── task7 ├── 9.2 ├── task1 ├── task11 ├── task4 ├── task12 ├── task9 ├── task6 ├── task3 ├── task2 ├── task5 ├── task7 ├── task10 └── task8 ├── 8.2 ├── task4 ├── task1 ├── task3 ├── task2 ├── task6 ├── task7 ├── task5 ├── task9 ├── task10 └── task8 └── README.md /10.2/task3.c: -------------------------------------------------------------------------------- 1 | printf("%d %d",*p_2, *p_1); -------------------------------------------------------------------------------- /10.2/task4.c: -------------------------------------------------------------------------------- 1 | printf("%d", *p_2 + *p_1); -------------------------------------------------------------------------------- /10.2/task5.c: -------------------------------------------------------------------------------- 1 | *p_dbl = (double)*p_1 / *p_2; -------------------------------------------------------------------------------- /10.2/task2.c: -------------------------------------------------------------------------------- 1 | char *p_ch = &ch; 2 | *p_ch = inp; -------------------------------------------------------------------------------- /10.2/task1.c: -------------------------------------------------------------------------------- 1 | int *p_a = &a; 2 | int *p_b = &b; 3 | -------------------------------------------------------------------------------- /10.1/task1.c: -------------------------------------------------------------------------------- 1 | int sum (int a, int b) { 2 | return a+b; 3 | } -------------------------------------------------------------------------------- /10.1/task2.c: -------------------------------------------------------------------------------- 1 | int min (int a, int b){ 2 | return a < b ? a: b; 3 | } 4 | -------------------------------------------------------------------------------- /10.2/task7.c: -------------------------------------------------------------------------------- 1 | int temp; 2 | temp = *p_1; 3 | *p_1 = *p_2; 4 | *p_2 = temp; -------------------------------------------------------------------------------- /10.2/task6.c: -------------------------------------------------------------------------------- 1 | int c = 0, d = 0; 2 | scanf("%d %d",&c,&d); 3 | *p_1 = c; 4 | *p_2 = d; -------------------------------------------------------------------------------- /10.3/task1.c: -------------------------------------------------------------------------------- 1 | void swap(int * a, int * b){ 2 | int temp; 3 | temp = *a; 4 | *a = *b; 5 | *b = temp; 6 | } -------------------------------------------------------------------------------- /10.1/task9.c: -------------------------------------------------------------------------------- 1 | void factors(int k){ 2 | for(int i = 1; i<=k; i++) 3 | if(k%i==0) 4 | printf("%d ",i); 5 | } -------------------------------------------------------------------------------- /3.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | printf("\"I'll be back!\"\n\t(c)Terminator"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /4.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | printf("%d", a%2); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.1/task10: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k = 0; 5 | scanf("%d", &k); 6 | printf("%d", !k); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task10: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%60); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task13: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%7); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k/10); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k*10); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%3600); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task14: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", (k+2)%7); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /10.3/task5.c: -------------------------------------------------------------------------------- 1 | void char_cesar(char * ch, int shift){ 2 | if (*ch + shift > 122) *ch = 97 + shift - (123 - *ch); 3 | else *ch += shift; 4 | } -------------------------------------------------------------------------------- /5.2/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%2==0 ? 1 : -1); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%2==0 ? 1 : -1); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k/10+k%10*100); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k/100+k%100*10); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.3/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0, x=0; 5 | scanf("%d%d", &k, &x); 6 | printf("%d", k%x); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /6.2/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int x, y; 5 | scanf("%d%d", &x, &y); 6 | printf(x==y ? "1" : "0"); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /4.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0, m=0; 5 | scanf("%d%d", &n, &m); 6 | printf("%d", (n+m)*2); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /4.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | printf("%.2lf", a*3.1415926/180); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /4.1/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | a%2==0 ? printf("1") : printf("0"); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | printf("%d %d", a/3600, a%3600/60); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.2/task11: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", k%7==0 ? k/7 : k/7+1); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /6.3/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int x; 5 | scanf("%d", &x); 6 | if (x>60) printf("Fire situation"); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /9.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char symb = "a"; 5 | scanf ("%c", &symb); 6 | printf ("%c", symb-32); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /1.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("NICKNAME: Neo\nCITY: St-Petersburg\nAGE: 35\nHEIGHT: 180\nWEIGHT: 75"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /10.1/task10.c: -------------------------------------------------------------------------------- 1 | int is_prime(int k){ 2 | for(int i = 1; i<=k; i++) { 3 | if(k%i==0 && i != 1 && i != k) return 0; 4 | } 5 | return 1; 6 | } -------------------------------------------------------------------------------- /4.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | printf("%d", n/100+n%100/10+n%10); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /5.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | printf("%d %d %d", a*a, a*a*6, a*a*a); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /6.3/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0, b=0; 5 | scanf("%d%d", &a, &b); 6 | printf(a 2 | 3 | int main() { 4 | printf("Wake up, Neo...\n\nThe Matrix has you...\n\nFollow the white rabbit..."); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /10.3/task6.c: -------------------------------------------------------------------------------- 1 | int gcd(int x, int y){ 2 | while (x !=0 && y != 0) { 3 | if (x > y ) x %= y; 4 | else y %= x; 5 | } 6 | return x+y; 7 | } -------------------------------------------------------------------------------- /5.1/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | printf("%d", a%10*100 + a%100/10*10 + a/100); 7 | 8 | return 0; 9 | } -------------------------------------------------------------------------------- /5.2/task12: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | printf("%d", (k+4)%7==0 ? (k+4)/7 : (k+4)/7+1); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /5.3/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0, x=0, y=0; 5 | scanf("%d%d%d", &k, &x, &y); 6 | printf("%d %d", x%k, y%k); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /10.3/task3.c: -------------------------------------------------------------------------------- 1 | void minmax(int * x, int * y){ 2 | if (*x > *y) { 3 | int temp; 4 | temp = *x; 5 | *x = *y; 6 | *y = temp; 7 | } 8 | } -------------------------------------------------------------------------------- /3.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | int h, m, s; 5 | scanf("%d%d%d", &h, &m, &s); 6 | printf("%d\n", h*60*60 + m*60 + s); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /4.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int a=0, b=0; 6 | scanf("%d%d", &a, &b); 7 | printf("%d", abs(b-a)); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /5.3/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double f=0; 5 | scanf("%lf", &f); 6 | double res = (f-32)*5/9; 7 | printf("%.2lf", res); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /3.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("S.Holmes:\n"); 5 | printf("51grad 31'25.48\" N\n"); 6 | printf("0 grad 9'29.93\" W\n"); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /4.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0, m=0; 5 | double k=0; 6 | scanf("%d%d%lf", &n, &m, &k); 7 | printf("%.2lf", (m-n)*k); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /9.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char symb = "a"; 5 | scanf ("%c", &symb); 6 | printf ("%c ", symb-1); 7 | printf ("%c", symb+1); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /3.2/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | int rub; 5 | double kurs, dollars; 6 | scanf("%d %lf", &rub, &kurs); 7 | printf("%lf\n", rub*kurs); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /4.2/task5: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int n; 6 | scanf("%u", &n); 7 | int res = pow (2, n); 8 | printf("%u", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | for (int i=1; i<=n; i++) 7 | { 8 | printf("%d ", i); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /10.3/task2.c: -------------------------------------------------------------------------------- 1 | void sum_digits(int * x){ 2 | int sum = 0; 3 | 4 | while (*x != 0) { 5 | sum += *x%10; 6 | *x /= 10; 7 | } 8 | 9 | *x = sum; 10 | } -------------------------------------------------------------------------------- /5.3/task1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0; 6 | scanf("%d", &k); 7 | int res = pow(2, (k/3)); 8 | printf("%d", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.2/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | do { 6 | scanf("%d", &n); 7 | printf("%d ", n); 8 | } while (n!=-9999); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /7.2/task11: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | while (n!=0) { 7 | printf("%d", n%10); 8 | n/=10; 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /7.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | do { 6 | scanf("%d", &n); 7 | if (n!=-9999) printf("%d ", n); 8 | } while (n!=-9999); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.2/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | do { 6 | scanf("%d", &n); 7 | if (n!=-9999) printf("%d ", n); 8 | } while (n!=-9999); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /9.3/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str1[40]; 5 | char str2[20]; 6 | scanf("%s%s", str1, str2); 7 | printf("%s.%s", str1, str2); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /10.3/task4.c: -------------------------------------------------------------------------------- 1 | void char_register(char * ch, int fl){ 2 | if (!fl) { 3 | if (*ch > 64 && *ch < 91) *ch += 32; 4 | } else { 5 | if (*ch > 96 && *ch < 123) *ch -= 32; 6 | } 7 | } -------------------------------------------------------------------------------- /4.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | float diametr=113, dlina=355; 5 | float pi=0; 6 | pi = dlina/diametr; 7 | printf("pi = %.5f\n",pi); 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /9.3/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | char str1[40] = "Hello, "; 5 | char str2[20]; 6 | scanf("%s", str2); 7 | printf("%s%s", str1, str2); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /4.2/task4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double a, b, c; 6 | scanf("%lf%lf%lf", &a, &b, &c); 7 | printf("%.2lf", (a*b*(sin(c/180*3.14159)/2))); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /5.3/task3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double f=0; 6 | scanf("%lf", &f); 7 | double res = f * 454 / 1000; 8 | printf("%.2lf", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.3/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | while(1==1) { 5 | int n=0; 6 | scanf("%d", &n); 7 | if (n>0) printf("%d ", n); 8 | if (n==0) break; 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /5.3/task9: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0, n=0, x=0; 6 | scanf("%d%d%d", &n, &k, &x); 7 | int res = (x+k)%n; 8 | printf("%d", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0, a=0; 5 | scanf("%d%d", &a, &n); 6 | for (int i=n; i>=a; i--) 7 | { 8 | printf("%d ", i); 9 | 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /7.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0, res=1; 5 | scanf("%d", &k); 6 | for (int i=1; i<=k; i++) { 7 | res*=i; 8 | } 9 | printf("%d", res); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /7.2/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | for (int i=1; i<=n; i++) { 7 | if (i*i<=n) printf("%d ", i*i); 8 | else return 0; 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /4.2/task1: -------------------------------------------------------------------------------- 1 | //Напишите вызов функции pow для возведения числа 2 в степень 5. Результат присвойте переменной с именем res. 2 | //Объявлять эту переменную заранее не нужно, она уже объявлена. 3 | 4 | res = pow (2, 5); -------------------------------------------------------------------------------- /4.2/task3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double a, b, c, d; 6 | scanf("%lf%lf%lf%lf", &a, &b, &c, &d); 7 | printf("%.2lf", sqrt((a-c)*(a-c)+(b-d)*(b-d))); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /6.3/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int b1, b2, b3; 5 | scanf("%d%d%d%d", &b1, &b2, &b3); 6 | if (b1*b2*b3==2*4*8) printf("open"); 7 | else printf("close"); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /3.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | 5 | for (int i=1; i<=5; i++){ 6 | for (int j=1; j<=5; j++) 7 | printf("%-5d",i*j); 8 | printf("\n"); 9 | } 10 | 11 | return(0); 12 | } -------------------------------------------------------------------------------- /5.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double a=0, b=0; 5 | scanf("%lf%lf", &a, &b); 6 | double res = b * 3.14159265358979323846 * a * a; 7 | printf("%.2lf %.2lf", res, res/3); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /5.1/task9: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0; 6 | scanf("%i", &k); 7 | long long int res = pow(2, 30)*k - pow (10, 9)*k; 8 | printf("%u", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /6.3/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int b; 5 | scanf("%d", &b); 6 | int res=0; 7 | if (b>500) res = 350+(b-500)*2; 8 | else res = 350; 9 | printf("%d", res); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /7.2/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | int k=0; 7 | while (n!=0) { 8 | n/=10; 9 | k++; 10 | } 11 | printf("%d", k); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /9.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int k = 0; 6 | scanf ("%d", &k); 7 | k--; 8 | printf ("%c%c", k+'A', k+'a'); 9 | 10 | 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /5.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | int cap = 249.5/0.05 * a; 7 | double mol = 249.5 * a / 3e-23; 8 | printf("%d %.3e", cap, mol); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /4.4/task1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void){ 6 | srand(time(NULL)); 7 | int rand_digit = rand()%3; 8 | printf("%d\n",rand_digit); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.2/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | for (int i=0; i<5; i++) 6 | { 7 | int x; 8 | scanf("%d", &x); 9 | a+=x*x; 10 | } 11 | printf("%d", a); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /5.3/task13: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double k=0; 6 | scanf("%lf", &k); 7 | double res = 1.29 * exp(-1*k*(1.25 * pow (10, -4))); 8 | printf("%.2lf", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.3/task14: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double k=0; 6 | scanf("%lf", &k); 7 | double res = 7.5 * 10 * exp(-1 * log(2) / 5570 *k); 8 | printf("%.2lf", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /10.2/task8.c: -------------------------------------------------------------------------------- 1 | if (*p_a < *p_b && *p_a < *p_c) { 2 | *p_b = *p_a; 3 | *p_c = *p_a; 4 | } else if (*p_b < *p_c) { 5 | *p_a = *p_b; 6 | *p_c = *p_b; 7 | } else { 8 | *p_a = *p_c; 9 | *p_b = *p_c; 10 | } -------------------------------------------------------------------------------- /6.3/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | for (int i=0; i<3; i++) 6 | { 7 | int a=0; 8 | scanf("%d", &a); 9 | if (a>0) n++; 10 | } 11 | printf("%d", n); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.2/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | for (int i=1; i<=n; i*=2) 7 | { 8 | if (i==n) {printf("YES"); return 0;} 9 | } 10 | printf("NO"); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /5.1/task14: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | long int x=0; 6 | scanf("%i", &x); 7 | long long int res = sqrt(4*x*x); 8 | printf("%i ", res); 9 | printf("%i", res/450); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /6.3/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int b1, b2, b3, b4; 5 | scanf("%d%d%d%d", &b1, &b2, &b3, &b4); 6 | if (b1==1 && b2==0 && b3==2 && b4==4) printf("open"); 7 | else printf("close"); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /7.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | int x=1, y=0; 6 | scanf("%d", &n); 7 | for (int i=0; i 2 | 3 | int main() { 4 | int sum = 0; 5 | int temp = 0; 6 | 7 | do { 8 | scanf("%d", &temp); 9 | sum+=temp; 10 | } while (temp!=0); 11 | 12 | printf("%d", sum); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /3.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | 5 | printf("N\t10*N\t100*N\t1000*N\n\n"); 6 | 7 | for (int i=1;i<=10;i++) { 8 | printf("%d\t%d\t%d\t%d\n",i,10*i,100*i,1000*i); 9 | } 10 | 11 | return(0); 12 | } -------------------------------------------------------------------------------- /5.1/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0; 5 | scanf("%d", &a); 6 | double b=1, c=1; 7 | b*=a/1000; 8 | c*=a%1000/100; 9 | b*=a%100/10; 10 | c*=a%10; 11 | printf("%.2lf", b/c); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /10.3/task8.c: -------------------------------------------------------------------------------- 1 | int abs_arr(int arr[], int n){ 2 | int counter = 0; 3 | for (int i=0; i 2 | 3 | int main() { 4 | int a=0, b=0; 5 | for (int i=0; i<5; i++) 6 | { 7 | int x; 8 | scanf("%d", &x); 9 | x%2==0 ? a++ : b++; 10 | } 11 | printf("%d", b-a); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0, a=0; 5 | scanf("%d%d", &a, &n); 6 | int i=0; 7 | if (a>0) i=a; 8 | else i=1; 9 | for (; i<=n; i++) 10 | { 11 | printf("%d ", i); 12 | } 13 | return 0; 14 | } -------------------------------------------------------------------------------- /4.4/task2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | int n=0; 7 | scanf("%d", &n); 8 | srand(time(NULL)); 9 | int rand_digit = rand()%n; 10 | printf("%d\n",rand_digit); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /5.3/task11: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0; 6 | scanf("%d", &k); 7 | int res = (k/1000+7)%10*10+(k%1000/100+7)%10+(k%100/10+7)%10*1000+(k%10+7)%10*100; 8 | printf("%d", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.3/task12: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0; 6 | scanf("%d", &k); 7 | int res = (k/1000+3)%10*10+(k%1000/100+3)%10+(k%100/10+3)%10*1000+(k%10+3)%10*100; 8 | printf("%d", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.3/task2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double d=0, f=0; 6 | scanf("%lf%lf", &f, &d); 7 | double res = (f * 12 + d) * 25.4 / 1000; 8 | printf("%.0lf\'%.0lf\" = %.2lfm.", f, d, res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /7.2/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | int k=1; 7 | for (int i=1; ;i++) { 8 | k*=2; 9 | if (k<=n) printf("%d ", i); 10 | else break; 11 | } 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /9.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int k = 0; 6 | scanf ("%d", &k); 7 | for (int i=0, j=26-k; i 2 | 3 | int main(void){ 4 | double a, b, c, d, e, f, h; 5 | scanf("%lf%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f, &h); 6 | double res = a/(b*(c/(d*(e/(f*h))))); 7 | printf("%.2f", res); 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double a=0, b=0; 5 | scanf("%lf%lf", &a, &b); 6 | double res = 3.14159265358979323846 * b * b * 100 - 3.14159265358979323846 * a * a * 100; 7 | printf("%.0lf %.2lf", b-a, res); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /5.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0, b=0; 5 | double c=0, d=0; 6 | scanf("%d%d",&a, &b); 7 | c = (int)(a/b)%10; 8 | d = (int)((double)a/b*10)%10; 9 | printf("%.0lf %.0lf", c, d); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /5.3/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0; 5 | scanf("%d", &k); 6 | int res=0; 7 | for (int i=0; i<4; i++) 8 | { 9 | res += k % 10 * pow(2, i); 10 | k/=10; 11 | } 12 | printf("%d", res); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /7.2/task10: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | int k=1; 7 | int i=1; 8 | while (k=n) break; 11 | i++; 12 | } 13 | printf("%d", i); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /1.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | for (int i=0; i<13; i++){ 5 | for (int j=0; j<49; j++){ 6 | if (i>0 && i<7 && j<8) printf("*"); 7 | else printf("_"); 8 | } 9 | if (i<13) printf("\n"); 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /4.3/task1: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double a, b, c; 6 | scanf("%lf%lf%lf", &a, &b, &c); 7 | double res = sqrt((a+b+c)/2*((a+b+c)/2-a)*((a+b+c)/2-b)*((a+b+c)/2-c)); 8 | printf("%.2lf", res); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /5.1/task12: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double e=1; 5 | double factorial=1; 6 | for (double i=1; i<6; i++) 7 | { 8 | factorial*=i; 9 | e+=1.0/factorial; 10 | if (i>2) printf("%.5lf\n", e); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /5.3/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int k=0, x=0; 5 | scanf("%d%d", &k, &x); 6 | int res=0; 7 | for (int i=0; i<4; i++) 8 | { 9 | res += x % 10 * pow(k, i); 10 | x/=10; 11 | } 12 | printf("%d", res); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /6.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double x, y; 5 | scanf("%lf%lf", &x, &y); 6 | if (x>0 && y>0) printf("1"); 7 | if (x<0 && y>0) printf("2"); 8 | if (x<0 && y<0) printf("3"); 9 | if (x>0 && y<0) printf("4"); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /9.3/task4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | char str1[40]; 6 | char str2[20]; 7 | scanf("%s%s", str1, str2); 8 | if (strcmp (str1, str2)) printf("no"); 9 | else printf("yes"); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /4.4/task3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | int n=0, e=0; 7 | scanf("%d%d", &n, &e); 8 | srand(time(NULL)); 9 | int rand_digit = n + rand()%(e-n); 10 | printf("%d\n",rand_digit); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /7.1/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0, b=0; 5 | scanf("%d%d", &a, &b); 6 | if (a<=0) a=1; 7 | for (int i=a; i<=b; i++) { 8 | for (int j=1; j<=i-a+1; j++) { 9 | printf("%5d", i); 10 | } 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.1/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a=0, b=0; 5 | scanf("%d%d", &a, &b); 6 | if (a<=0) a=1; 7 | for (int i=a; i<=b; i++) { 8 | for (int j=1; j<=i; j++) { 9 | printf("%4d", i); 10 | } 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.3/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf("%d", &n); 6 | for (int j=1; j<=n; j++) { 7 | for (int i=1; i<=j; i++){ 8 | printf("%d ", i); 9 | } 10 | printf("\n"); 11 | } 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /3.2/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int a, b, res; 5 | 6 | scanf("%d %d", &a, &b); 7 | res = a + b; 8 | 9 | int c; 10 | 11 | scanf("%d", &c); 12 | 13 | res = res - c; 14 | 15 | printf("%d\n", res); 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /1.1/task1.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | //Напишите программу, которая выводит на экран следующие строки: 4 | //Hello, World! 5 | //The world is yours! 6 | 7 | 8 | #include 9 | 10 | int main() { 11 | 12 | printf("Hello, World!\nThe world is yours!"); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /5.1/task11: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int factorial=1; 5 | for (int i=1; i<10; i++) 6 | { 7 | factorial*=i; 8 | printf("%d! = %7d\n", i, factorial); 9 | } 10 | factorial*=10; 11 | printf("10!= %7d\n", factorial); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /5.3/task10: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int k=0, n=0, x=0; 6 | scanf("%d", &k); 7 | for (int i=0; i<4; i++) { 8 | int x=0; 9 | scanf("%d", &x); 10 | int res = (x+k)%26; 11 | printf("%d ", res); 12 | } 13 | return 0; 14 | } -------------------------------------------------------------------------------- /7.2/task12: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double eps, e = 1; 5 | int k = 1, i = 1; 6 | scanf("%lf", &eps); 7 | while ( e += 1./k ) 8 | { 9 | if ( 1./k < eps ) break; 10 | k *= ++i; 11 | } printf("%.8lf", e); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.1/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n=0; 5 | scanf("%d", &n); 6 | int k=0; 7 | for(int i=1; i<=n; i++) { 8 | if (n%i==0) { 9 | printf("%d ", i); 10 | k++; 11 | } 12 | } 13 | printf("\n%d", k); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /6.3/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int d=0; 5 | scanf("%d",&d); 6 | if (d<7) printf("дошкольник"); 7 | if (d>=7 && d<19) printf("школьник"); 8 | if (d>=19 && d<60) printf("рабочий"); 9 | if (d>=60) printf("пенсионер"); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /8.1/task1: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int arr[n]; 7 | for (int i=0; i=0; i--) { 11 | printf ("%d ", arr[i]); 12 | } 13 | return 0; 14 | } -------------------------------------------------------------------------------- /8.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double sum = 0; 5 | int n = 0; 6 | scanf ("%d", &n); 7 | for (int i=0; i 2 | 3 | int main() { 4 | int n=0, a=0; 5 | scanf("%d%d", &a, &n); 6 | int i=0; 7 | if (a>0) i=a; 8 | else i=1; 9 | int k=0; 10 | for (; i<=n; i++){ 11 | printf("%d ", i); 12 | k++; 13 | } 14 | printf("\n%d", k); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /7.3/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | for (int i=1; i<=100; i++) { 5 | if (i%3==0 && i%5==0) printf(" FizzBuzz"); 6 | else if (i%3==0) printf(" Fizz"); 7 | else if (i%5==0) printf(" Buzz"); 8 | else printf(" %d", i); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /6.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | setlocale(LC_ALL, ""); 6 | int s; 7 | scanf("%d",&s); 8 | 9 | switch (s%2) { 10 | case 0 : printf("Не любит\n"); break; 11 | case 1 : printf("Любит\n"); break; 12 | } 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /7.1/task11: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int N = 0; 5 | scanf("%d", &N); 6 | int max = -9999; 7 | int number = 0; 8 | for (int i=1; i<=N; i++){ 9 | scanf("%d", &number); 10 | if (max < number) max = number; 11 | } 12 | printf("%d\n", max); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /10.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int min(int a, int b, int c){ 4 | if (a < b && a < c) return a; 5 | else if (b < c) return b; 6 | else return c; 7 | } 8 | int main(void){ 9 | int a, b, c; 10 | scanf ("%d%d%d", &a, &b, &c); 11 | printf ("%d", min (a, b, c)); 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /10.1/task4.c: -------------------------------------------------------------------------------- 1 | int factorial(int k){ 2 | int fact = 1; 3 | for (int i=1; i<=k; i++) { 4 | fact *=i; 5 | } 6 | return fact; 7 | } 8 | 9 | int main(void){ 10 | int k; 11 | scanf("%d", &k); 12 | 13 | printf("%d", factorial(k)); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /6.1/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int age=0; 5 | scanf("%d", &age); 6 | if (age%10==1 && age/10!=1) printf("Мне %d год", age); 7 | else if ((age%10==2 || age%10==3 || age%10==4) && age/10!=1) printf("Мне %d года", age); 8 | else printf("Мне %d лет", age); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /6.3/task4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double x1=0, y1=0, x2=0, y2=0; 6 | scanf("%lf%lf", &x1, &y1); 7 | scanf("%lf%lf", &x2, &y2); 8 | double r1 = sqrt (x1*x1+y1*y1); 9 | double r2 = sqrt (x2*x2+y2*y2); 10 | printf(r1 2 | 3 | int main() { 4 | 5 | int k = 0; 6 | while (1) { 7 | char symb = 'a'; 8 | scanf ("%c", &symb); 9 | if (symb == '\0') break; 10 | k++; 11 | } 12 | 13 | printf ("%d", k); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /7.2/task14: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int a = 0, b = 0; 5 | int d = 0; 6 | 7 | scanf("%d %d", &a, &b); 8 | 9 | if (a > b) d = a; 10 | else d = b; 11 | 12 | while(d%a!=0 || d%b!=0){ 13 | d++; 14 | } 15 | 16 | printf("%d\n", d); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /10.3/task7.c: -------------------------------------------------------------------------------- 1 | int gcd(int x, int y){ 2 | while (x !=0 && y != 0) { 3 | if (x > y ) x %= y; 4 | else y %= x; 5 | } 6 | return x+y; 7 | } 8 | 9 | void reduce_fraction(int * a, int * b){ 10 | int x = *a, y = *b; 11 | int del = gcd (x, y); 12 | *a /= del; 13 | *b /= del; 14 | } -------------------------------------------------------------------------------- /7.2/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int max=-9999; 5 | int temp=0; 6 | int min=9999; 7 | do { 8 | scanf("%d", &temp); 9 | if (temp>=max && temp!=0) max=temp; 10 | if (temp<=min && temp!=0) min=temp; 11 | } while (temp!=0); 12 | printf("%d %d", max, min); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /7.3/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int flag = -1; 5 | int sum = 0; 6 | int number = 0; 7 | while(flag != 1) { 8 | scanf("%d", &number); 9 | if (number == 0) flag++; 10 | if (flag == 0) sum += number; 11 | } 12 | 13 | printf("%d ", sum); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /7.3/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | _Bool flag = 0; 5 | int number = 0; 6 | while(number != -9999) { 7 | scanf("%d", &number); 8 | if (number == -9999) break; 9 | if (flag) printf("%d ", number); 10 | if (number == 2517) flag = 1; 11 | } 12 | 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /9.2/task11: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[100]; 5 | int i=0; 6 | while (1) { 7 | int count = scanf ("%s", &str); 8 | if (count <=0) break; 9 | int length = strlen(str); 10 | if (str[0]==str[length-1]) printf ("%s ", str); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /7.3/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int index = 0; 6 | scanf("%d", &n); 7 | int now = 0; 8 | int last; 9 | while(index < n) { 10 | scanf("%d", &now); 11 | if (now != last) printf("%d ", now); 12 | last = now; 13 | index++; 14 | } 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /9.2/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[100]; 5 | scanf("%s", str); 6 | int length = strlen (str); 7 | int sum = 0; 8 | for (int i=length-1, j=1; i>=0; i--, j*=2){ 9 | int istr = str[i] - '0'; 10 | sum += istr * j; 11 | } 12 | printf ("%d", sum); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /9.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | char symb = 'a'; 6 | scanf ("%c ", &symb); 7 | if (symb > 64 && symb < 91 || symb > 96 && symb < 123) printf ("en"); 8 | else if (symb > 47 && symb < 58) printf ("digit"); 9 | else printf ("error"); 10 | 11 | 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /10.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sequence_multipliers(int k){ 4 | for (int i=1; ; i++) { 5 | if (i*(i+1)*(i+2)==k) return i; 6 | if (i*(i+1)*(i+2)>k) return -1; 7 | } 8 | } 9 | 10 | int main(void){ 11 | int n = 0; 12 | scanf("%d",&n); 13 | 14 | printf("%d",sequence_multipliers(n)); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /8.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | _Bool flag = 1; 5 | int n = 0; 6 | scanf ("%d", &n); 7 | int arr[n]; 8 | for (int i=0; ij; i--, j++) { 12 | if (arr[i] != arr[j]) flag = 0; 13 | } 14 | printf (flag ? "YES" : "NO"); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /8.2/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int matrix[n][n]; 7 | for (int i=0; ij) printf ("%d ", i-j+1); 10 | else printf ("%d ", j-i+1); 11 | } 12 | 13 | printf ("\n"); 14 | } 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Решение курса на Степик: Основы программирования на C. Задачи. 2 | 5 | # Ссылка на курс: https://stepik.org/course/3078/syllabus 6 | -------------------------------------------------------------------------------- /5.1/task13: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | double e=1; 6 | double factorial=1; 7 | double x = 0; 8 | scanf("%lf", &x); 9 | for (double i=1; i<6; i++) 10 | { 11 | factorial*=i; 12 | e+=pow(x, i)/factorial; 13 | } 14 | double ex = exp(x); 15 | printf("%.6lf\n", ex); 16 | printf("%.6lf\n", e); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /9.3/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char symb = 'a'; 5 | int sum1 = 0, sum2 = 0, count = 0; 6 | 7 | while (count < 6) { 8 | scanf ("%c", &symb); 9 | if (count < 3 ) sum1 += (int)symb - '0'; 10 | else sum2 += (int)symb - '0'; 11 | count++; 12 | } 13 | 14 | printf ( sum1 == sum2 ? "yes" : "no"); 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /8.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int arr[n]; 7 | for (int i=0; i 2 | 3 | int main() { 4 | int n = 0; 5 | int m = 0; 6 | scanf ("%d", &n); 7 | scanf ("%d", &m); 8 | 9 | for (int i=0; i 2 | #include 3 | 4 | int main() { 5 | int n, res; 6 | scanf("%d",&n); 7 | for(int i=2; i <= sqrt(n); i++) { 8 | res=n%i; 9 | if (res == 0 && i != n) { 10 | printf ("0"); 11 | return 0; 12 | } 13 | } 14 | printf ("1"); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /10.3/task9.c: -------------------------------------------------------------------------------- 1 | int minmax(int arr[], int n, int fl){ 2 | int res = 0; 3 | if (fl) { 4 | res = -999999; 5 | for (int i=0; i arr[i]) res = arr[i]; 12 | } 13 | } 14 | return res; 15 | } -------------------------------------------------------------------------------- /7.3/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | _Bool flag = 1; 5 | int number = 1; 6 | int index = 0; 7 | while(number != -9999) { 8 | scanf("%d", &number); 9 | if (number != -9999 && number <= 0 || index == 0 && number == -9999) flag = 0; 10 | index++; 11 | } 12 | 13 | if (flag) printf("YES"); 14 | else printf("NO"); 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /9.2/task12: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[100]; 5 | while (1) { 6 | int count = scanf ("%s", &str); 7 | if (count <=0) break; 8 | int length = strlen(str); 9 | for (int j=strlen(str)-1; j>=0; j--) { 10 | printf ("%c", str[j]); 11 | } 12 | 13 | printf (" "); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /9.2/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str[100]; 5 | scanf ("%s", &str); 6 | int count = 0; 7 | int first = strlen (str) % 3; 8 | for (int i=0; i 2 | 3 | int main(void){ 4 | int m, d; 5 | scanf("%d%d", &m, &d); 6 | switch (m) 7 | { 8 | case 1 : printf("%d", d); break; 9 | case 2 : printf("%d", (d/10) * (d%10)); break; 10 | case 3 : printf("%d", (d/100) * (d%100/10) * (d%10)); break; 11 | case 4 : printf("%d", (d/1000) * (d%1000/100) * (d%100/10) * (d%10)); break; 12 | } 13 | return 0; 14 | } -------------------------------------------------------------------------------- /8.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int flag = 0; 6 | scanf ("%d", &n); 7 | int arr[n]; 8 | for (int i=0; i 2 | 3 | int main(void) { 4 | int a = 0, k = 0; 5 | int res = 0; 6 | 7 | scanf("%d %d", &a, &k); 8 | res = 1; 9 | 10 | while(k) { 11 | if (k % 2 == 0) { 12 | k /= 2; 13 | a *= a; 14 | } 15 | else { 16 | k--; 17 | res *= a; 18 | } 19 | } 20 | printf("%d\n", res); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /7.3/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | _Bool flag = 1; 5 | int now = 0; 6 | int last = -9999; 7 | while(now != -9999) { 8 | scanf("%d", &now); 9 | if (now <= last && now != -9999) { 10 | flag = 0; 11 | break; 12 | } 13 | last = now; 14 | 15 | } 16 | 17 | if (flag) printf("YES"); 18 | else printf("NO"); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /10.1/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void square(int x, char c){ 4 | for (int i=0; i 2 | #include 3 | int main(void) { 4 | setlocale(LC_ALL, ""); 5 | char s; 6 | scanf("%c",&s); 7 | 8 | switch (s) { 9 | default : break; 10 | case 'l' : printf("коня потеряешь, себя спасёшь!\n"); break; 11 | case 'f' : printf("и себя и коня потеряешь!\n"); break; 12 | case 'r' : printf("себя потеряешь, коня спасёшь!\n"); break; 13 | } 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /7.3/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int res = 0; 5 | int index = 1; 6 | int now = 0; 7 | int last = -9999; 8 | while(now != -9999) { 9 | scanf("%d", &now); 10 | if (now <= last && now != -9999) { 11 | res = index; 12 | break; 13 | } 14 | last = now; 15 | index++; 16 | 17 | } 18 | 19 | printf("%d", res); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /8.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int flag = 0; 6 | scanf ("%d", &n); 7 | int arr[n]; 8 | for (int i=0; i arr[0]) { 13 | printf ("%d ", arr[i]); 14 | flag = 1; 15 | } 16 | } 17 | if (!flag) printf ("0"); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /10.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int factorial(int p){ 4 | int fact = 1; 5 | for (int i=1; i<=p; i++) { 6 | fact *=i; 7 | } 8 | return fact; 9 | } 10 | 11 | int combin(int n, int k){ 12 | return factorial(n)/(factorial(k)*factorial(n-k)); 13 | } 14 | 15 | int main(void){ 16 | int n = 0, k = 0; 17 | scanf("%d%d",&n,&k); 18 | 19 | printf("%d",combin(n,k)); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /10.3/task12.c: -------------------------------------------------------------------------------- 1 | int binary_search(int arr[], int n, int arg){ 2 | int first = 0; 3 | int last = n; 4 | int res = -1; 5 | 6 | while (last >= first) { 7 | int mid = (last + first) / 2; 8 | 9 | if ( arg < arr[mid]) { 10 | last = mid - 1; 11 | } else if (arg > arr[mid]) { 12 | first = mid + 1; 13 | } else { 14 | res = mid; 15 | break; 16 | } 17 | } 18 | return res; 19 | } -------------------------------------------------------------------------------- /9.1/task3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int arr[26] ={0}; 7 | 8 | for (int i=0; i<=n; i++) { 9 | char symb = 'a'; 10 | scanf ("%c ", &symb); 11 | if (symb > 64 && symb < 91) symb += 32; 12 | arr[symb-'a']++; 13 | 14 | } 15 | 16 | for (int i=0; i<26; i++) { 17 | printf ("%d ", arr[i]); 18 | } 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /9.2/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | char str1[13]; 5 | char str2[13]; 6 | for (int i=0; i < 13; i++) { 7 | str1[i]=0; 8 | str2[i]=0; 9 | } 10 | 11 | scanf("%s", str1); 12 | scanf("%s", str2); 13 | 14 | int count = 0; 15 | 16 | for (int i=0; i < 13; i++) { 17 | if (str1[i] != str2[i]) count++; 18 | } 19 | 20 | printf ("%d", count); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /6.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | setlocale(LC_ALL, ""); 6 | int s; 7 | scanf("%d",&s); 8 | 9 | switch (s) { 10 | case 1 : printf("плохо\n"); break; 11 | case 2 : printf("неудовлетворительно\n"); break; 12 | case 3 : printf("удовлетворительно\n"); break; 13 | case 4 : printf("хорошо\n"); break; 14 | case 5 : printf("отлично\n"); break; 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /8.1/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int arr[n/2]; 7 | 8 | for (int i=0; i 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int matrix[n][n]; 7 | for (int i=0; i=0; j--){ 14 | printf ("%d ", j+1); 15 | } 16 | } 17 | printf ("\n"); 18 | } 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /6.1/task5: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | double a=0, b=0; 7 | char s; 8 | scanf("%lf%lf %c", &a, &b, &s); 9 | switch (s) 10 | { 11 | default : printf("ERROR!"); break; 12 | case '+' : printf("%.2lf", a+b); break; 13 | case '-' : printf("%.2lf", a-b); break; 14 | case '*' : printf("%.2lf", a*b); break; 15 | case '/' : printf(b==0 ? "ERROR!" : "%.2lf", a/b); break; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /8.1/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | double sum = 0; 5 | int n = 0; 6 | scanf ("%d", &n); 7 | int arr[n]; 8 | 9 | for (int i=0; imean) printf ("%d ", arr[i]); 16 | } 17 | for (int i=0; i 2 | 3 | int main() { 4 | 5 | int index = -1; 6 | char searchSymb = 'a'; 7 | scanf ("%c\n", &searchSymb); 8 | char symb = 'a'; 9 | int counter = 0; 10 | 11 | while (1) { 12 | scanf ("%c", &symb); 13 | if (symb == '\n') break; 14 | if (symb == searchSymb) index = counter; 15 | counter++; 16 | } 17 | 18 | printf ("%d", index); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /6.1/task4: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) { 5 | setlocale(LC_ALL, ""); 6 | char s; 7 | double a=0, b=0; 8 | scanf("%c",&s); 9 | scanf("%lf%lf", &a, &b); 10 | switch (s) { 11 | default : printf("ERROR!"); break; 12 | case '+' : printf("%.2lf", a+b); break; 13 | case '-' : printf("%.2lf", a-b); break; 14 | case '*' : printf("%.2lf", a*b); break; 15 | case '/' : printf("%.2lf", a/b); break; 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /8.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int m = 0; 6 | scanf ("%d", &n); 7 | scanf ("%d", &m); 8 | int matrix[n][m]; 9 | for (int i=0; i 2 | #include 3 | 4 | int main() { 5 | char str1[40]; 6 | char str2[20]; 7 | scanf("%s%s", str1, str2); 8 | for (int i=0; i 2 | 3 | int main() { 4 | int n = 0; 5 | int sum1 = 0; 6 | int sum2 = 0; 7 | scanf ("%d", &n); 8 | 9 | for (int i=0; i 0) sum1 += temp; 14 | if (n-j-i <= 0) sum2 += temp; 15 | } 16 | } 17 | if (sum1 > sum2) printf ("%d %d", sum2, sum1); 18 | else printf ("%d %d", sum1, sum2); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /9.2/task2: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int k = 0; 6 | char lastSymb = ' '; 7 | char symb = 'a'; 8 | 9 | while (1) { 10 | scanf ("%c", &symb); 11 | if (symb == '\n') { 12 | if ( lastSymb != ' ') k++; 13 | break; 14 | } 15 | if (symb == ' ' && lastSymb != ' ') k++; 16 | lastSymb = symb; 17 | } 18 | 19 | printf ("%d", k); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /6.3/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | int d,m; 5 | scanf("%d%d",&d,&m); 6 | switch (m) 7 | { 8 | case 2: 9 | if (1<=d && d<=29) 10 | printf("correct"); 11 | else 12 | printf("error"); 13 | break; 14 | default: 15 | if 16 | (1<=d && d<=30 && 1<=m && m<=12) 17 | printf("correct"); 18 | else 19 | printf("error"); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /8.2/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int m = 0; 6 | scanf ("%d", &n); 7 | scanf ("%d", &m); 8 | int arr[m]; 9 | for (int i=0; i=0; i--) { 21 | printf ("%d ", arr[i]); 22 | } 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /3.1/task2: -------------------------------------------------------------------------------- 1 | #include 2 | int main(void){ 3 | int a=3, b=4; 4 | double res = 0.75; 5 | 6 | printf("||-----|-----|-----|-----||\n"); 7 | printf("|| act | one | two | res ||\n"); 8 | printf("||=====+=====+=====+=====||\n"); 9 | printf("||%5c|%-5d|%-5d|%5.5d||\n",'+',a,b,a+b); 10 | printf("||%5c|%5d|%5d|%5.4d||\n",'-',a,b,a-b); 11 | printf("||%5c|%5d|%-5d|%5.5d||\n",'*',a,b,a*b); 12 | printf("||%-5c|%-5d|%5d|%5.3f||\n",'/',a,b,res); 13 | printf("==========================="); 14 | 15 | return(0); 16 | } -------------------------------------------------------------------------------- /6.3/task10: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int arr[3]; 5 | for (int i=0; i<3; i++) { 6 | scanf ("%d", &arr[i]); 7 | } 8 | for(int i = 0 ; i < 3 - 1; i++) { 9 | for(int j = 0 ; j < 3 - i - 1 ; j++) { 10 | if(arr[j] > arr[j+1]) { 11 | int tmp = arr[j]; 12 | arr[j] = arr[j+1] ; 13 | arr[j+1] = tmp; 14 | } 15 | } 16 | } 17 | for (int i=0; i<3; i++) { 18 | printf ("%d ", arr[i]); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /9.3/task5: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | char str1[50] = {0}; 7 | char str2[50] = {0}; 8 | 9 | scanf("%[^\n]%*c", &str1); 10 | scanf("%[^\n]%*c", &str2); 11 | 12 | for (int i=0; i 2 | 3 | void print_date(int d, int m, int y, int k){ 4 | if (k==0) { 5 | printf ("%02d.%02d.%02d", d, m, y%100); 6 | } 7 | else if (k==1) { 8 | printf ("%02d.%02d.%d", d, m, y); 9 | } 10 | else { 11 | printf ("%d/%02d/%02d", y, m, d); 12 | } 13 | return 0; 14 | } 15 | 16 | int main(){ 17 | int day = 0, month = 0, year = 0, form = 0; 18 | 19 | scanf("%d%d%d%d",&day, &month, &year, &form); 20 | 21 | print_date(day, month, year, form); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /6.1/task6: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void){ 4 | char sex; 5 | int age, height, weight; 6 | double bov_m, bov_f; 7 | scanf("%c", &sex); 8 | scanf("%d", &age); 9 | scanf("%d", &height); 10 | scanf("%d", &weight); 11 | bov_m = 10*weight + 6.25*height - 5*age + 5; 12 | bov_f = 10*weight + 6.25*height - 5*age - 161; 13 | switch (sex) 14 | { 15 | default : printf("ERROR!"); break; 16 | case 'f' : printf("| BMR |\n"); printf("|%.2f|\n",bov_f); break; 17 | case 'm' : printf("| BMR |\n"); printf("|%.2f|\n",bov_m); break; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /9.2/task5: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | int k = 0; 6 | char lastSymb = ' '; 7 | char symb = 'a'; 8 | 9 | while (1) { 10 | scanf ("%c", &symb); 11 | if (lastSymb == ' ' && symb == ' ') { 12 | lastSymb = symb; 13 | continue; 14 | } 15 | if (symb == '\n') { 16 | if (lastSymb != ' ') printf ("%c", lastSymb); 17 | break; 18 | } 19 | printf ("%c", lastSymb); 20 | lastSymb = symb; 21 | } 22 | 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /9.2/task7: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int x=0, y=0, vector, N; 5 | char str[5]; 6 | scanf("%d",&N); 7 | for(int i=0;i 2 | 3 | int main() { 4 | int multMain = 1; 5 | int multAnti = 1; 6 | int n = 0; 7 | scanf ("%d", &n); 8 | if (n==1) { 9 | printf ("%d %d", multAnti, multMain); 10 | return 0; 11 | } 12 | int arr[n*n]; 13 | for (int i=0; i multAnti) printf ("%d %d", multMain, multAnti); 23 | else printf ("%d %d", multAnti, multMain); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /9.3/task7: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | char symb = 'a'; 7 | int arr1[27] = {0}, arr2[27] = {0}; 8 | while (symb != '\n') { 9 | scanf ("%c", &symb); 10 | arr1[symb-'a']++; 11 | } 12 | 13 | symb = 'a'; 14 | 15 | while (symb != '\n') { 16 | scanf ("%c", &symb); 17 | arr2[symb-'a']++; 18 | } 19 | 20 | int flag = 1; 21 | 22 | for (int i=0; i<27; i++) { 23 | if (arr1[i] < arr2[i]) { 24 | flag = 0; 25 | //break; 26 | } 27 | } 28 | 29 | printf ( flag ? "yes" : "no"); 30 | 31 | return 0; 32 | } -------------------------------------------------------------------------------- /8.1/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | scanf ("%d", &n); 6 | int min = 9999; 7 | int max = 0; 8 | int indexMin = 0; 9 | int indexMax = 0; 10 | 11 | int arr[n]; 12 | 13 | for (int i=0; i max) { 16 | max = arr[i]; 17 | indexMax = i; 18 | } 19 | if (arr[i] < min) { 20 | min = arr[i]; 21 | indexMin = i; 22 | } 23 | } 24 | 25 | arr[indexMin] = max; 26 | arr[indexMax] = min; 27 | 28 | for (int i=0; i 2 | 3 | int main() { 4 | char str[100]; 5 | scanf ("%s", &str); 6 | int flag = 0; 7 | for (int i=0; i 58) && str[i] != '.' && str[0] != '-' && str[0] != '+') { 9 | flag = 3; 10 | break; 11 | } 12 | if (str[i] == '.') { 13 | flag++; 14 | if ((i == strlen (str)-1 || i == 0 ) || (str[i-1] == '+' || str [i-1] =='-')) flag++; 15 | } 16 | } 17 | if (flag == 1) printf ("float"); 18 | else if (flag == 0) printf ("int"); 19 | else printf ("error"); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /9.3/task8: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | char symb = 'a'; 7 | char *morse[36] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----."}; 8 | while (1) { 9 | scanf ("%c", &symb); 10 | if (symb == '\n') break; 11 | symb = tolower (symb); 12 | if (symb == ' ') printf ("|:_..._:|"); 13 | else if (symb > 47 && symb <58) printf ("%s|", morse[symb-'0'+27]); 14 | else printf ("%s|", morse[symb-'a']); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /8.2/task9: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int k = 0; 6 | scanf ("%d", &n); 7 | int arr[n][n]; 8 | for (int i=0; in) k %= n; 17 | 18 | int newArr[n][n]; 19 | 20 | for (int i=0; i= n) newArr[i][j+k-n] = arr[i][j]; 24 | else newArr[i][j+k] = arr[i][j]; 25 | } 26 | 27 | } 28 | for (int i=0; i 2 | 3 | int main() { 4 | int flag = 1; 5 | int indexBeg = -1; 6 | int indexEnd = 0; 7 | char str[100]; 8 | scanf ("%[^\n]%*c", &str); 9 | for (int i=0; i indexBeg) { 17 | indexEnd = i+1; 18 | break; 19 | } 20 | } 21 | for (int i=0; i 2 | 3 | int main(void){ 4 | int m, d; 5 | scanf("%d%d", &m, &d); 6 | switch (m) 7 | { 8 | case 1 : printf("%d", d); break; 9 | case 2 : printf("%d", d+31); break; 10 | case 3 : printf("%d", d+31+28); break; 11 | case 4 : printf("%d", d+31+28+31); break; 12 | case 5 : printf("%d", d+31+28+31+30); break; 13 | case 6 : printf("%d", d+31+28+31+30+31); break; 14 | case 7 : printf("%d", d+31+28+31+30+31+30); break; 15 | case 8 : printf("%d", d+31+28+31+30+31+30+31); break; 16 | case 9 : printf("%d", d+31+28+31+30+31+30+31+31); break; 17 | case 10 : printf("%d", d+31+28+31+30+31+30+31+31+30); break; 18 | case 11 : printf("%d", d+31+28+31+30+31+30+31+31+30+31); break; 19 | case 12 : printf("%d", d+31+28+31+30+31+30+31+31+30+31+30); break; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /8.2/task10: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int N, M; 4 | scanf("%d%d", &N, &M); 5 | int mat[N][M]; 6 | int number = 1; 7 | 8 | for(int i = 0; i <= N/2; i++) { 9 | for( int x = i; x < M-i; x++ ) { 10 | if( number <= N*M) { 11 | mat[i][x] = number++; 12 | } 13 | } 14 | 15 | for( int y = 1+i; y < N-1-i; y++) { 16 | if( number <= N*M) 17 | { 18 | mat[y][M-1-i]= number++; 19 | } 20 | } 21 | 22 | for( int x = i; x < M-i; x++){ 23 | if( number <= N*M) 24 | { 25 | mat[N-1-i][M-1-x] = number++; 26 | } 27 | } 28 | 29 | for( int y = 1+i; y < N-1-i; y++){ 30 | if( number <= N*M) { 31 | mat[N- 1 -y][i] = number++; 32 | } 33 | } 34 | 35 | } 36 | 37 | 38 | for(int y = 0; y < N; y++) { 39 | for(int x = 0; x < M; x++) { 40 | printf("%3d", mat[y][x]); 41 | 42 | } 43 | printf("\n"); 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /8.2/task8: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int n = 0; 5 | int m = 0; 6 | scanf ("%d", &n); 7 | scanf ("%d", &m); 8 | int arr[n][m]; 9 | int arrSum [m]; 10 | 11 | for (int i=0; i sumMax) { 38 | sumMax = arrSum[i]; 39 | indexMax = i; 40 | } 41 | } 42 | 43 | int newArr[n][m]; 44 | 45 | for (int i=0; i mid) { 12 | b--; 13 | } 14 | if (a <= b) { 15 | int temp = array[a]; 16 | array[a] = array[b]; 17 | array[b] = temp; 18 | a++; 19 | b--; 20 | } 21 | 22 | } 23 | if (first < b) qsortMinMax(array, first, b); 24 | if (end > a) qsortMinMax(array, a, end); 25 | } 26 | void qsortMaxMin (int array[], int first, int end) { 27 | int a = first; 28 | int b = end; 29 | int mid = array[(a+b)/2]; 30 | 31 | while (a <= b) { 32 | while (array[a] > mid) { 33 | a++; 34 | } 35 | while (array[b] < mid) { 36 | b--; 37 | } 38 | if (a <= b) { 39 | int temp = array[a]; 40 | array[a] = array[b]; 41 | array[b] = temp; 42 | a++; 43 | b--; 44 | } 45 | 46 | } 47 | if (first < b) qsortMaxMin(array, first, b); 48 | if (end > a) qsortMaxMin(array, a, end); 49 | } 50 | 51 | if (fl ) qsortMaxMin (arr, 0, n-1); 52 | else qsortMinMax (arr, 0, n-1); 53 | 54 | } --------------------------------------------------------------------------------