Facebook
From Eduardo, 3 Years ago, written in C#.
This paste is a reply to Convert from c# to python from Eduardo - view diff
Embed
Download Paste or View Raw
Hits: 102
  1. /*You have an array (called myArray) with 5 elements (integers in the range of 1 to 100). Write a program in CTM that prints the highest number of the array (if repeated, only print once). The program should only print the number, without any text.
  2.  
  3. The code that fills the array is already written, but you can edit it to test with other values. With the refresh button you can retrieve the original value that will be used to evaluate the question as correct or incorrect during execution.
  4. */
  5. myArray = [13,2,4,35,1]
  6.   int mayor = 0;
  7.  
  8.  
  9. for (int i = 0; i < myArray.Length; i++){
  10.   if(myArray[i] < 1 || myArray[i]>100 ){
  11.     Console.WriteLine("enteros fuera del rango de 1 a 100"); break;
  12.   }
  13.   if(i > mayor){
  14.     mayor= myArray[i];
  15.   }
  16.  
  17. }
  18.  
  19. if(mayor > 0){
  20.   Console.WriteLine(mayor);
  21. }
  22.