Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Is it a stochastic matrix?
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
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 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[,] matrix = {{100}}; //int[,] matrix = {{42}}; //int[,] matrix = {{100, 0}, {0, 100}}; //int[,] matrix = { { 4, 8, 15 }, { 16, 23, 42 }, { 80, 69, 43 } }; //int[,] matrix = {{99,1}, {2,98} }; int[,] matrix = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; Console.WriteLine(F(matrix)); } private static int F(int[,] m) { int x, i, j, r, c, e, w; x = m.GetLength(0); e = w = 1; for (i = 0; i < x; i++) { r = 0; c = 0; for (j = 0; j < x; j++) { r += m[i, j]; c += m[j, i]; } if (r != 100) e = 0; if (c != 100) w = 0; } if (e == 1 && w == 1) return 3; if (e == 1) return 1; return w == 1 ? 2 : 4; } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0,12 sec, absolute running time: 0,08 sec, cpu time: 0,08 sec, average memory usage: 13 Mb, average nr of threads: 3
edit mode
|
history
|
discussion
4