Advertisement
MonsterScripter

CodinGame_2023_08_23__23_11_00__affine.c

Aug 23rd, 2023
1,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5.  
  6. /**
  7.  * Le programme :
  8.  * Votre programme doit calculer la valeur d'une fonction affine aux points donnés.
  9.  *
  10.  * Une fonction affine est une fonction de la forme f(x) = a * x + b avec a et b, deux constantes.
  11.  * On vous donne a, b et un ensemble de N valeurs de x. Vous devez calculer la valeur de f(x) pour les N valeurs de x.
  12.  */
  13.  
  14. int main()
  15. {
  16.     int a;
  17.     int b;
  18.     scanf("%d%d", &a, &b);
  19.     int n;
  20.     scanf("%d", &n);
  21.     for (int i = 0; i < n; i++) {
  22.         int x;
  23.         scanf("%d", &x);
  24.         printf("%d\n", a*x+b);
  25.     }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement