Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Student Cables
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int num = 3;//Convert.ToInt32(Console.ReadLine()); long[] cable = new long[num]; string[] type = new string[num]; long result = 0; /*for (int i = 0; i < num; i++) { cable[i] = Convert.ToInt32(Console.ReadLine()); type[i] = Console.ReadLine(); } */ cable[0] = 116; type[0] = "centimeters"; cable[1] = 4; type[1] = "meters"; cable[2] = 20; type[2] = "centimeters"; //cable[3] = 120; //type[3] = "centimeters"; int sides = cable.Length; for (int i = 0; i < num; i++) { //checks if cable is larger than 20 cm if (cable[i] < 20 && type[i] == "centimeters") { cable[i] = 0; sides--; } if (type[i] == "meters") { cable[i] = cable[i] * 100; } //Console.WriteLine(cable[i]); result = result + cable[i]; } result = result - (sides - 1) * 3; //Console.WriteLine(result); //Creates the new cable Console.WriteLine(result); long newCable = 504; long numberOfCables = (result / newCable); //Console.WriteLine(numberOfCables); long finalCable = 504 * numberOfCables; long leftCable = (result - finalCable); Console.WriteLine(numberOfCables); Console.WriteLine(leftCable); } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0.08 sec, absolute running time: 0.06 sec, cpu time: 0.05 sec, average memory usage: 14 Mb, average nr of threads: 3
edit mode
|
history
|
discussion
530 1 -982