Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
150115_MatrizTodosDistintos
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
//Title of this code //gcc 4.8.2 #include <stdio.h> short todosValoresDistintosArray(long d, long v[d]); short todosValoresDistintosMatriz(long F, long C, long m[F][C]); int main(void) { long v[10] = {1, 2, 3, 4, 5, 5, 6, 7, 8, 9}; long m[3][4] = {{1, 2, 3, 4},{5, 6, 7, 8},{9, 0, 11, 22}}; if(todosValoresDistintosArray(10, v)) { printf("ARRAY : SÍ TODOS DISTINTOS\n"); } else { printf("ARRAY : NO TODOS DISTINTOS\n"); } if(todosValoresDistintosMatriz(3, 4, m)) { printf("MATRIZ: SÍ TODOS DISTINTOS\n"); } else { printf("MATRIZ: NO TODOS DISTINTOS\n"); } return 0; } short todosValoresDistintosArray(long d, long v[d]) { long i, j; for(i = 0 ; i < d ; i++) { for(j = i + 1 ; j < d ; j++) { if(v[i] == v[j]) return 0; } } return 1; } short todosValoresDistintosMatriz(long F, long C, long m[F][C]) { long i, j; long d = F * C; for(i = 0 ; i < d ; i++) { for(j = i + 1 ; j < d ; j++) { if(m[i/C][i%C] == m[j/C][j%C]) return 0; } } return 1; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.12 sec, absolute running time: 0.14 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0.27 sec
edit mode
|
history
|
discussion
ARRAY : NO TODOS DISTINTOS MATRIZ: SÍ TODOS DISTINTOS