Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. class projluca
  3. {
  4.     static void Main()
  5.     {
  6.         Random r = new Random();
  7.         int nbA = 0;
  8.         int m = 0;
  9.         int nbB = 0;
  10.         int nbC = 0;
  11.         double res = 0;
  12.         Console.WriteLine("A=5   B=2   C=0.1");
  13.         while (res!=100)
  14.         {
  15.             nbA = r.Next(1, 99);
  16.             m = 100 - nbA;
  17.             nbB = r.Next(1, m + 1);
  18.             nbC = 100 - nbB - nbA;
  19.             res = acc(nbA, nbB, nbC);
  20.             if(res==100)
  21.             {
  22.                 Console.WriteLine("Il y a " + nbA + " A");
  23.                 Console.WriteLine("Il y a " + nbB + " B");
  24.                 Console.WriteLine("Il y a " + nbC + " C");
  25.             }
  26.         }
  27.     }
  28.     public static double acc(int r, int s, int t)
  29.     {
  30.         double a = 5;
  31.         double b = 2;
  32.         double c = 0.1;
  33.         double f = 0;
  34.         f = r * a + s * b + t * c;
  35.         return f;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement