Advertisement
LePetitGlacon

FICHE 6.5 : Exercice 5

Nov 25th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 16.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace o
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             string[,] monTab2D = new string[6,5];
  10.             int compteurtableau = 0;
  11.            
  12.            
  13.             for(int iLig = 0; iLig < 6 ; iLig ++)
  14.             {
  15.                 for(int iCol = 0; iCol < 5 ; iCol ++)
  16.                 {
  17.                     if(iCol == 0 && iLig == 0)
  18.                             {
  19.                                 Console.WriteLine("XXXX");
  20.                             }
  21.                     else
  22.                     {
  23.                     if(iLig == 0 && (iCol >= 1 || iCol <= 4))
  24.                     {
  25.                         Console.WriteLine("Modèle de voiture");
  26.                         monTab2D[iLig,iCol] = Console.ReadLine();
  27.                     }
  28.                     else{
  29.                         if(iCol == 0 && (iLig >= 1 || iCol <= 5))
  30.                     {
  31.                         Console.WriteLine("Nom vendeur");
  32.                         monTab2D[iLig,iCol] = Console.ReadLine();
  33.                     }
  34.                        
  35.                             else
  36.                             {
  37.                                 Console.WriteLine("Valeur ligne {0} colonne {1} vendeur {2} modèle {3}",iLig,iCol, monTab2D[iLig,0],  monTab2D[0,iCol]);
  38.                                 monTab2D[iLig,iCol] = Console.ReadLine();
  39.                             }
  40.                         }
  41.                     }
  42.                 }}
  43.             Console.WriteLine("\t");
  44.             for(int iLig = 0; iLig <6 ; iLig ++)
  45.             {
  46.                
  47.                 for(int iCol = 0; iCol <5 ; iCol ++, compteurtableau++)
  48.                 {
  49.                    
  50.                     Console.Write(" {0}\t", monTab2D[iLig, iCol]);
  51.                    
  52.                     if (compteurtableau == 4){
  53.                         Console.WriteLine();
  54.                         compteurtableau = -1;
  55.                     }
  56.                  }
  57.                
  58.             }
  59.            
  60.             Console.ReadKey();
  61.         }
  62.     }
  63. }
  64. ------------------------------------------------------------------------------------------------------------------------------------
  65. using System;
  66.  
  67. namespace u
  68. {
  69.     class Program
  70.     {
  71.         public static void Main(string[] args)
  72.         {
  73.             string[,] monTab2D = new string[,]{ {  "",       "twingo", "clio", "mégane", "vel satis" },
  74.                                                 { "andré",      "0",    "3",    "2",    "0" },
  75.                                                 { "ingemar",    "2",    "3",    "0",    "1"},
  76.                                                 { "jean-jérôme","1",    "1",    "1",    "1"},
  77.                                                 { "Cindy",      "5",    "1",    "0",    "0"},
  78.                                                 { "Joey",       "1",    "1",    "2",    "0"}};
  79.  
  80.             int twingo = 0, clio = 0, megane = 0, velsatis = 0;
  81.             string nombreT = "", nombreC = "", nombreM = "", nombreV = "";
  82.  
  83.  
  84.             for (int iLig = 0; iLig < 6; iLig++)
  85.             {
  86.                 for (int iCol = 0; iCol < 5; iCol++)
  87.                 {
  88.  
  89.  
  90.                     if (iCol == 1 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  91.                     {
  92.                         nombreT = monTab2D[iLig, iCol];
  93.                         twingo = twingo + int.Parse(nombreT);
  94.                     }
  95.                     else
  96.                     {
  97.                         if (iCol == 2 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  98.                         {
  99.                             nombreC = monTab2D[iLig, iCol];
  100.                             clio = clio + int.Parse(nombreC);
  101.                         }
  102.                         else
  103.                         {
  104.                             if (iCol == 3 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  105.                             {
  106.                                 nombreM = monTab2D[iLig, iCol];
  107.                                 megane = megane + int.Parse(nombreM);
  108.                             }
  109.                             else
  110.                             {
  111.                                 if (iCol == 4 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  112.                                 {
  113.                                     nombreV = monTab2D[iLig, iCol];
  114.                                     velsatis = velsatis + int.Parse(nombreV);
  115.                                 }
  116.                             }
  117.                         }
  118.                     }
  119.                 }
  120.             }
  121.  
  122.             //AFICHAGE VALEURS
  123.             Console.WriteLine("Il y a eu {0} twingo de vendu",twingo);
  124.             Console.WriteLine("Il y a eu {0} clio de vendu", clio);
  125.             Console.WriteLine("Il y a eu {0} megane de vendu", megane);
  126.             Console.WriteLine("Il y a eu {0} vel satis de vendu", velsatis);
  127.  
  128.                 Console.ReadKey();
  129.            
  130.         }
  131.     }
  132. }
  133. ------------------------------------------------------------------------------------------------------------------------
  134.  
  135. using System;
  136.  
  137. namespace u
  138. {
  139.     class Program
  140.     {
  141.         public static void Main(string[] args)
  142.         {
  143.             string[,] monTab2D = new string[,]{ {  "",       "twingo", "clio", "mégane", "vel satis" },
  144.                                                 { "andré",      "0",    "3",    "2",    "0" },
  145.                                                 { "ingemar",    "2",    "3",    "0",    "1"},
  146.                                                 { "jean-jérôme","1",    "1",    "1",    "1"},
  147.                                                 { "Cindy",      "5",    "1",    "0",    "0"},
  148.                                                 { "Joey",       "1",    "1",    "2",    "0"}};
  149.  
  150.             int twingo = 0, clio = 0, megane = 0, velsatis = 0;
  151.             int andré = 0, ingemar = 0, jeanj = 0, cindy = 0, joey = 0;
  152.            
  153.             string nombreT = "", nombreC = "", nombreM = "", nombreV = "";
  154.             string nombreAn = "", nombreIn = "", nombreJJ = "", nombreCi = "", nombreJo = "";
  155.             string unPourTous;
  156.            
  157.             int tandré = 0, candré = 0, mandré = 0, vandré = 0;
  158.             int tingemar = 0, cingemar = 0, mingemar = 0, vingemar = 0;
  159.             int tjeanj = 0, cjeanj = 0, mjeanj = 0, vjeanj = 0;
  160.             int tcindy = 0, ccindy = 0, mcindy = 0, vcindy = 0;
  161.             int tjoey = 0, cjoey = 0, mjoey = 0, vjoey = 0;
  162.        
  163.             //for savoir qui a vendu combien de quoi
  164.             for (int iLig = 0; iLig < 6; iLig++)
  165.             {
  166.                 for (int iCol = 0; iCol < 5; iCol++)
  167.                 {
  168.  
  169.  
  170.                     if (iLig == 1 && (iCol >= 1 || (iCol >= 1 && iCol <= 4)))
  171.                     {
  172.                         nombreAn = monTab2D[iLig, iCol];
  173.                         andré = andré + int.Parse(nombreAn);
  174.                     }
  175.                     else
  176.                     {
  177.                         if (iLig == 2 && (iCol >= 1 || (iCol >= 1 && iCol <= 4)))
  178.                         {
  179.                             nombreIn = monTab2D[iLig, iCol];
  180.                             ingemar = ingemar + int.Parse(nombreIn);
  181.                         }
  182.                         else
  183.                         {
  184.                             if (iLig == 3 && (iCol >= 1 || (iCol >= 1 && iCol <= 4)))
  185.                             {
  186.                                 nombreJJ = monTab2D[iLig, iCol];
  187.                                 jeanj = jeanj + int.Parse(nombreJJ);
  188.                             }
  189.                             else
  190.                             {
  191.                                 if (iLig == 4 && (iCol >= 1 || (iCol >= 1 && iCol <= 4)))
  192.                                 {
  193.                                     nombreCi = monTab2D[iLig, iCol];
  194.                                     cindy = cindy + int.Parse(nombreCi);
  195.                                 }
  196.                                 else
  197.                                 {
  198.                                     if (iLig == 5 && (iCol >= 1 || (iCol >= 1 && iCol <= 4)))
  199.                                     {
  200.                                         nombreJo = monTab2D[iLig, iCol];
  201.                                         joey = joey + int.Parse(nombreJo);
  202.                                     }
  203.                                 }
  204.                             }
  205.                         }  
  206.                     }
  207.                 }
  208.             }
  209.            
  210.             //for savoir combien de voiture on été vendu
  211.             for (int iLig = 0; iLig < 6; iLig++)
  212.             {
  213.                 for (int iCol = 0; iCol < 5; iCol++)
  214.                 {
  215.                     if (iCol == 1 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  216.                     {
  217.                         nombreT = monTab2D[iLig, iCol];
  218.                         twingo = twingo + int.Parse(nombreT);
  219.                     }
  220.                     else
  221.                     {
  222.                         if (iCol == 2 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  223.                         {
  224.                             nombreC = monTab2D[iLig, iCol];
  225.                             clio = clio + int.Parse(nombreC);
  226.                         }
  227.                         else
  228.                         {
  229.                             if (iCol == 3 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  230.                             {
  231.                                 nombreM = monTab2D[iLig, iCol];
  232.                                 megane = megane + int.Parse(nombreM);
  233.                             }
  234.                             else
  235.                             {
  236.                                 if (iCol == 4 && (iLig >= 1 || (iLig >= 1 && iLig <= 4)))
  237.                                 {
  238.                                     nombreV = monTab2D[iLig, iCol];
  239.                                     velsatis = velsatis + int.Parse(nombreV);
  240.                                 }
  241.                             }
  242.                         }
  243.                     }
  244.                 }
  245.             }
  246.            
  247.             //for qui a vendu quoi a combien d'exemplaire
  248.             for (int iLig = 0; iLig < 6; iLig++)
  249.             {
  250.                 for (int iCol = 0; iCol < 5; iCol++)
  251.                 {
  252.  
  253.     //ANDRé
  254. if (iLig == 1 && iCol == 1)
  255. {//ANDRé
  256.     unPourTous = monTab2D[iLig, iCol];
  257.     tandré = tandré + int.Parse(unPourTous);
  258.     unPourTous = 0;
  259. }
  260. else
  261. {
  262.     if (iLig == 1 && iCol == 2)
  263.     {//ANDRé
  264.         candré = candré + int.Parse(unPourTous);
  265.     }
  266.     else
  267.     {
  268.         if (iLig == 1 && iCol == 3)
  269.         {//ANDRé
  270.             mandré = mandré + int.Parse(unPourTous);
  271.         }
  272.         else
  273.         {
  274.             if (iLig == 1 && iCol == 4)
  275.             {//ANDRé
  276.                 vandré = vandré + int.Parse(unPourTous);
  277.             }
  278.                                                 //INGEMAR
  279.                                                 else
  280.                                                 {
  281.                                                     if (iLig == 2 && iCol == 1)
  282.                                                     {//ingemar
  283.                                                         tingemar = tingemar + int.Parse(unPourTous);
  284.                                                     }
  285.                                                     else
  286.                                                     {
  287.                                                         if (iLig == 2 && iCol == 1)
  288.                                                         {//ingemar
  289.                                                             cingemar = cingemar + int.Parse(unPourTous);
  290.                                                         }
  291.                                                         else
  292.                                                         {
  293.                                                             if (iLig == 2 && iCol == 1)
  294.                                                             {//ingemar
  295.                                                                 mingemar = mingemar + int.Parse(unPourTous);
  296.                                                             }
  297.                                                             else
  298.                                                             {
  299.                                                                 if (iLig == 2 && iCol == 1)
  300.                                                                 {//ingemar
  301.                                                                     vingemar = vingemar + int.Parse(unPourTous);
  302.                                                                 }
  303.     //JEAN J                                                           
  304.                 else
  305.     {
  306.         if (iLig == 3 && iCol == 1)
  307.         {//JJ
  308.             tjeanj = tjeanj + int.Parse(unPourTous);
  309.         }
  310.         else
  311.         {
  312.             if (iLig == 3 && iCol == 1)
  313.             {//JJ
  314.                 cjeanj = cjeanj + int.Parse(unPourTous);
  315.             }
  316.             else
  317.             {
  318.                 if (iLig == 3 && iCol == 1)
  319.                 {//JJ
  320.                     mjeanj = mjeanj + int.Parse(unPourTous);
  321.                 }
  322.                 else
  323.                 {
  324.                     if (iLig == 3 && iCol == 1)
  325.                     {//JJ
  326.                         vjeanj = vjeanj + int.Parse(unPourTous);
  327.                     }
  328.                                                         //CINDY
  329.                                                         else
  330.                                                         {
  331.                                                             if (iLig == 4 && iCol == 1)
  332.                                                             {//cindy
  333.                                                                 tcindy = tcindy + int.Parse(unPourTous);
  334.                                                             }
  335.                                                             else
  336.                                                             {
  337.                                                                 if (iLig == 4 && iCol == 1)
  338.                                                                 {//cindy
  339.                                                                     ccindy = ccindy + int.Parse(unPourTous);
  340.                                                                 }
  341.                                                                 else
  342.                                                                 {
  343.                                                                     if (iLig == 4 && iCol == 1)
  344.                                                                     {//cindy
  345.                                                                         mcindy = mcindy + int.Parse(unPourTous);
  346.                                                                     }
  347.                                                                     else
  348.                                                                     {
  349.                                                                         if (iLig == 4 && iCol == 1)
  350.                                                                         {//cindy
  351.                                                                             vcindy = vcindy + int.Parse(unPourTous);
  352.                                                                         }
  353.                                                                         else
  354. //JOEY
  355. {
  356.     if (iLig == 5 && iCol == 1)
  357.     {//joey
  358.         tjoey = tjoey + int.Parse(unPourTous);
  359.     }
  360.     else
  361.     {
  362.         if (iLig == 5 && iCol == 2)
  363.         {//joey
  364.             cjoey = cjoey + int.Parse(unPourTous);
  365.         }
  366.         else
  367.         {
  368.             if (iLig == 5 && iCol == 3)
  369.             {//joey
  370.                 mjoey = mjoey + int.Parse(unPourTous);
  371.             }
  372.             else
  373.             {
  374.                 if (iLig == 5 && iCol == 4)
  375.                 {//joey
  376.                     vjoey = vjoey + int.Parse(unPourTous);
  377.                 }
  378.                                 }
  379.                             }
  380.                         }  
  381.                     }
  382.                 }
  383.             }
  384.                                                                
  385. }
  386. }
  387.             }}}}}}}}}}}}}
  388.                
  389.            
  390.  
  391.             //AFICHAGE VALEURS
  392.             Console.WriteLine("Il y a eu {0} twingo de vendu",twingo);
  393.             Console.WriteLine("Il y a eu {0} clio de vendu", clio);
  394.             Console.WriteLine("Il y a eu {0} megane de vendu", megane);
  395.             Console.WriteLine("Il y a eu {0} vel satis de vendu", velsatis);
  396.             Console.WriteLine();
  397.             Console.WriteLine("André a vendu {0} voiture",andré);
  398.             Console.WriteLine("ingemar a vendu {0} voiture",ingemar);
  399.             Console.WriteLine("Jean J a vendu {0} voiture",jeanj);
  400.             Console.WriteLine("Cindy a vendu {0} voiture",cindy);
  401.             Console.WriteLine("Joey a vendu {0} voiture",joey);
  402.             Console.WriteLine();
  403.             Console.WriteLine("André a vendu {0} twingo, {1} clio,{2} mégane et {3} vel satis",tandré,candré,mandré,vandré);
  404.             Console.WriteLine("André a vendu {0} twingo, {1} clio,{2} mégane et {3} vel satis",tingemar,cingemar,mingemar,vingemar);
  405.             Console.WriteLine("André a vendu {0} twingo, {1} clio,{2} mégane et {3} vel satis",tjeanj,cjeanj,mjeanj,vjeanj);
  406.             Console.WriteLine("André a vendu {0} twingo, {1} clio,{2} mégane et {3} vel satis",tcindy,ccindy,mcindy,vcindy);
  407.             Console.WriteLine("André a vendu {0} twingo, {1} clio,{2} mégane et {3} vel satis",tjoey,cjoey,mjoey,vjoey);
  408.            
  409.             Console.ReadKey();
  410. }
  411. }
  412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement