/*I want conver this code to python
Write a program in C-C that walks through an array and generates a histogram based on the numbers in the array. The array is named myArray and contains 10 elements that correspond to integers from 1 to 5. A histogram represents that both an element appears in a dataset. For example, for the array: myArray:-(1,2,1,3,3,1,2,1,5,1) the histogram would look like this:
1: *****
2: **
3: **
4:
5: *
*/
string uno = "", dos = "", tres = "", cuatro = "", cinco = ""; bool valido = true;
for (int i = 0; i < myArray.Length; i++){ if(myArray[i] < 1 || myArray[i]>5 ){ valido = false;
break;
}
switch(myArray[i]){ case 1:
uno += "*";
break;
case 2: dos += "*"; break; case 3: tres += "*"; break; case 4:
cuatro += "*"; break;
case 5: cinco += "*"; break;
}
}
if(!valido){
Console.WriteLine("enteros fuera del rango de 1 a 5");
}else{
Console.WriteLine("1: "+uno); Console.WriteLine("2: "+dos); Console.WriteLine("3: "+tres); Console.WriteLine("4: "+cuatro); Console.WriteLine("5: "+cinco);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}