Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.78 KB | None | 0 0
  1. // ---------------- 1 ----------------
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5.  
  6. int main() {
  7.     double a, x, y;
  8.     for (a = 4; a < 6.1; a += 0.2) {
  9.         for (x = 3; x <= 5; x += 0.5) {
  10.             if (x != a) {
  11.                 y = sqrt(x * x + a * a) / (x - a);
  12.                 printf("\ta = %lf, x = %lf\n\ty = %lf\n", a, x, y);
  13.             }
  14.         }
  15.     }
  16. }
  17. // ---------------- 2 ----------------
  18. #include <stdio.h>
  19. #include <math.h>
  20.  
  21.  
  22. int main() {
  23.     double e, x, c, result = 0;
  24.     unsigned n = 1;
  25.     scanf("%lf%lf", &x, &e);
  26.     c = e;
  27.     for(short digit = 1; c >= e; digit *= -1, ++n) {
  28.         c = digit * pow(x, 2 * n - 1) / (4 * n * n - 1);
  29.         result += c;
  30.     }
  31.     printf("%lf", result);
  32. }
  33.  
  34. // ---------------- 3 ----------------
  35. #include <stdio.h>
  36.  
  37. int main() {
  38.     FILE* input = fopen("input.txt", "r");
  39.     unsigned a, b;
  40.     fscanf(input, "%u%u", &a, &b);
  41.     int matrix[a][b];
  42.     for (unsigned i = 0; i < a; ++i) {
  43.         for (unsigned j = 0; j < b; ++j) {
  44.             fscanf(input, "%i", &matrix[i][j]);
  45.         }
  46.     }
  47.     fclose(input);
  48.     FILE* output = fopen("output.txt", "w");
  49.     for (unsigned i = 0; i < a; ++i) {
  50.         for (unsigned j = 0; j < b; ++j) {
  51.             fprintf(output, "%4i ", matrix[j][i]);
  52.         }
  53.         fprintf(output, "\n");
  54.     }
  55.     fclose(output);
  56. }
  57. // ---------------- 4 ----------------
  58. #include <stdio.h>
  59. #include <string.h>
  60.  
  61. int main() {
  62.    char sentence[BUFSIZ];
  63.    gets(sentence);
  64.    FILE* output = freopen("output.txt", "w", stdout);
  65.    char separators[] = " ,.";
  66.    char* word = strtok(sentence, separators);
  67.    while (word != NULL) {
  68.        if (strlen(word) % 2 != 0) {
  69.            printf("%s ", word);
  70.        }
  71.        word = strtok(NULL, separators);
  72.    }
  73.    fclose(output);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement