#include <stdio.h>
#include<stdlib.h>
#include<time.h>
void randy(int array[] ){
int i = 0 , d = 0;
for(i = 1 ; i <= 23 ; i++){
array[i] = 1 + (rand() % 365 );
}
}
int compare (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
int find (int arr[]){
int d = 0;
for(d = 1 ;d <=23 ; d++ ){
if(arr[d] == arr[d + 1]){
return 1;
}
}
return 0;
}
int main(void){
double count_birthday = 0;
int people[24];
srand(time(NULL));
int c = 0 ;
long double ip = 0;
while(ip++ <= 1000000 ){
randy(people);
qsort (people, 25, sizeof(int), compare);
if(find (people) == 1 ){
count_birthday++;
}
}
printf("%.2lf", count_birthday / 10000 );
return 0;
}
public static returnTrue(boolean b){
if (b){
return true;
} else {
return true;
}
}
When you want your function always returns the correct value
// powtierdzenie decyzji
function zapytaj(pytanie){
if(confirm(pytanie)) return true
else return false;
}
if (responseCode / 100 == 2) {//success
return handleSuccess();
} else if (responseCode == 401) {
return handleNotAuthorized();
} else {
// something else
}
var list = new List<string>() { // Assume some items in the list };
for (var i = 0; i < list.Count; i++)
{
var item = list[i];
list.Remove(item);
i--;
}
Simple alternative to List.Clear()
/// <summary>
/// Returns true if any component of of Vector3 v is negative
/// </summary>
public static bool Ext_IsNegative(this Vector3 v)
{
return v.x < 0f && v.y < 0f && v.z < 0f;
}
Either the description is wrong or the method in itself
private <T> Supplier<T> abort(Class<T> exception) {
return () -> {
try {
return exception.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
};
}
...
throw abort(MyException.class).get();
public function getProfilePicture(Company $company, $id, $url = null) {
// @TODO: Figure out how to do this.
return null;
}
this.props.HeaderStore.setHeader(true, null, false, false, true, true,'dashboardNavigation');
<?
if (ini_get('register_globals') != 1){
if ((isset($_POST) == true) && (is_array($_POST) == true)) extract($_POST, EXTR_OVERWRITE);
if ((isset($_GET) == true) && (is_array($_GET) == true)) extract($_GET, EXTR_OVERWRITE);}
" ".split(" ");
Very weird code found multiple times in old code base.
class Timer extends React.Component{
state ={
time: 10
};
setInvt = () =>{
let t = this.state.time
if(t<=1){
clearInterval(this.invertal)
}
this.setState({time: t-1})
}
componentDidMount(){
this.invertal = setInterval(this.setInvt, 1000)
}
render(){
return (<label>{this.state.time}</label>)
}
}
export {Timer}
case ClientMessage:
if (*XGetAtomName(GLWin.dpy, event.xclient.message_type)
== *"WM_PROTOCOLS")
{ printf("Exiting sanely...\n");
done = True;
}
break;
someone just want to watch the world burn
Map<Object, List<Element>> groupeUniqueMap =values.stream().collect(Collectors.groupingBy(this::getCompositeGroupKey, Collectors.toList()));
if(groupeUniqueMap.containsKey(Arrays.asList(null,null,null,null,null,null,null)))
return values;
return doReturn();
ierr = pxmlIn->GetData(pcTag, *pTData);
*pbDataValid = bool((ierr==0)&&(iLen>0)); // enabled if: not empty string and vaild (number?)
if (*pbDataValid) iErr += ierr;