“mengembalikan tuple atau nol” Kode Jawaban

mengembalikan tuple atau nol

# return tuple or null
def solve s,g 
  s % g != 0 ? -1 : [g, s - g]
end
# FYI: the problem to solve is:
# Given the sum and gcd of two numbers, return the two numbers in ascending order. 
Mackerel

mengembalikan tuple atau nol

// return tuple or null
#include <stdlib.h>

int *gdc_sum(int sum, int gcd) {
  int   *res = malloc(sizeof(int) * 2);
  res[0] = gcd;
  res[1] = sum - gcd;
  return sum % gcd != 0 ? (NULL) : (res);
}
// FYI: the problem to solve is:
// Given the sum and gcd of two numbers, return the two numbers in ascending order. 
Mackerel

mengembalikan tuple atau nol

// return a tuple or null
fn solve(sum: u32, gcd: u32) -> Option<(u32, u32)> {
    if sum % gcd != 0 {
        None
    } else {
        Some((gcd, sum - gcd))
    }
}
// FYI: the problem solved is:
// Given the sum and gcd of two numbers, return the two numbers in ascending order. 
Mackerel

mengembalikan tuple atau nol

package kata

func Solve(s int, g int) []int {
  if s % g != 0 {
    return []int{-1, -1}
  }
  return []int{g, s - g}
}
// FYI: the problem to solve is:
// Given the sum and gcd of two numbers, return the two numbers in ascending order. 
Mackerel

mengembalikan tuple atau nol

// return tuple or null
using namespace std;

pair<int, int> solve(int s, int g){  
    return (s % g != 0) ? make_pair(-1, -1) : make_pair(g, s - g);  
}
// FYI: the problem to solve is:
// Given the sum and gcd of two numbers, return the two numbers in ascending order. 
Mackerel

Jawaban yang mirip dengan “mengembalikan tuple atau nol”

Pertanyaan yang mirip dengan “mengembalikan tuple atau nol”

Lebih banyak jawaban terkait untuk “mengembalikan tuple atau nol” di C

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya