- 1
- 2
- 3
- 4
- 5
public static Date getMinDate(List<Date> dates) {
Preconditions.checkArgument(dates != null && !dates.isEmpty(), "Dates list must be not null and not empty");
dates.sort(Comparator.naturalOrder());
return dates.get(0);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
public static Date getMinDate(List<Date> dates) {
Preconditions.checkArgument(dates != null && !dates.isEmpty(), "Dates list must be not null and not empty");
dates.sort(Comparator.naturalOrder());
return dates.get(0);
}
ну а че
+1
// 3.7 Position-independent Limitation
// At runtime an MRE program needs to be dynamically loaded into RAM. In other words, the addresses of the variables and functions can be dynamically assigned when they are loaded. This requires that the code be position-independent. If the code needs to determine the addresses at compile time, then it will fail to compile.
// The following code exemplifies this error.
/* 1 */
int a[10], b[10];
struct c {
int* d;
int* e;
};
struct c f = {a, b};
/* 2 */
void func1(void) {}
typedef struct struct1 {
int a;
void (*fun)(void);
} struct1;
struct1 array1[1] = {0, func1};
/* 3 */
char *str = "test";
char * list[] = {"zero", "one", "two"};
// The solution is as follows:
/* 1 */
int a[10], b[10];
struct c {
int* d;
int* e;
};
struct c f;
void init1(void) {
f.d = a;
f.e = b;
}
/* 2 */
void func1(void) {}
typedef struct struct1 {
int a;
void (*fun)(void);
} struct1;
struct1 array1[1];
void init2(void) {
array1[0].a = 0;
array1[0].fun = func1;
}
/* 3 */
char str[] = "test";
char list[][10] = {"zero", "one", "two"};
MRE Developer FAQ
This document contains information that is proprietary to MediaTek Inc.
Загрузчик программ из MRE не умеет сложные фиксапы, поэтому изменяйте свой код, чтобы в нём не было адресов, которые нужно определять в момент загрузки.
+2
#include "stdio.h"
#include "conio.h"
#define infinity 999
namespace belugina
{
void dij(int n,int v,int cost[10][10],int dist[])
{
int i,u,count,w,flag[10],min;
for(i=1;i<=n;i++)
flag[i]=0,dist[i]=cost[v][i];
count=2;
while(count<=n)
{
min=99;
for(w=1;w<=n;w++)
if(dist[w]<min && !flag[w])
min=dist[w],u=w;
flag[u]=1;
count++;
for(w=1;w<=n;w++)
if((dist[u]+cost[u][w]<dist[w]) && !flag[w])
dist[w]=dist[u]+cost[u][w];
}
}
}
Я разгадала знак бесконечности.
#define infinity 999
+2
bool End_Range (FILE * f){
int tmp;
tmp = fgetc(f);
tmp = fgetc(f);
if (tmp != '\'') fseek(f,-2,1);
else fseek(f,1,1);
return tmp == '\'' ? true : false;
}
void Natural_Merging_Sort (char *name){
int s1, s2, a1, a2, mark; FILE *f, *f1, *f2; s1 = s2 = 1;
while ( s1 > 0 && s2 > 0 ){
mark = 1; s1 = 0; s2 = 0;
f = fopen(name,"r"); f1 = fopen("nmsort_1","w");
f2 = fopen("nmsort_2","w"); fscanf(f,"%d",&a1);
if ( !feof(f) ) fprintf(f1,"%d ",a1);
if ( !feof(f) ) fscanf(f,"%d",&a2);
while ( !feof(f) ){
if ( a2 < a1 ) {switch (mark) {
case 1:{fprintf(f1,"' "); mark = 2; s1++; break;}
case 2:{fprintf(f2,"' "); mark = 1; s2++; break;}
}}
if ( mark == 1 ) { fprintf(f1,"%d ",a2); s1++; }
else { fprintf(f2,"%d ",a2); s2++;}
a1 = a2; fscanf(f,"%d",&a2);
}
if ( s2 > 0 && mark == 2 ) { fprintf(f2,"'");}
if ( s1 > 0 && mark == 1 ) { fprintf(f1,"'");}
fclose(f2); fclose(f1); fclose(f);
cout << endl;
Print_File(name);
Print_File("nmsort_1");
Print_File("nmsort_2");
cout << endl;
f = fopen(name,"w"); f1 = fopen("nmsort_1","r");
f2 = fopen("nmsort_2","r");
if ( !feof(f1) ) fscanf(f1,"%d",&a1);
if ( !feof(f2) ) fscanf(f2,"%d",&a2);
bool file1, file2;
while ( !feof(f1) && !feof(f2) ){ file1 = file2 = false;
while ( !file1 && !file2 ) {
if ( a1 <= a2 ) { fprintf(f,"%d ",a1);
file1 = End_Range(f1); fscanf(f1,"%d",&a1); }
else { fprintf(f,"%d ",a2); file2 = End_Range(f2);
fscanf(f2,"%d",&a2); }
}
while ( !file1 ) { fprintf(f,"%d ",a1);
file1 = End_Range(f1); fscanf(f1,"%d",&a1); }
while ( !file2 ) { fprintf(f,"%d ",a2);
file2 = End_Range(f2); fscanf(f2,"%d",&a2); }
} file1 = file2 = false;
while ( !file1 && !feof(f1) ) { fprintf(f,"%d ",a1);
file1 = End_Range(f1); fscanf(f1,"%d",&a1); }
while ( !file2 && !feof(f2) ) { fprintf(f,"%d ",a2);
file2 = End_Range(f2); fscanf(f2,"%d",&a2); }
fclose(f2); fclose(f1); fclose(f);
} remove("nmsort_1"); remove("nmsort_2");
}
Потеряли пульт от телевизора? Найди его бинарным поиском!!!
0
integers =: adverb def 'i.u'
5 integers
0 1 2 3 4
plus =: adverb def '(}:u) + {:u'
2 3 plus
5
1 2 3 1 plus
2 3 4
inc =: adverb def '(u , 1) plus'
5 inc
6
5 integers inc
1 2 3 4 5
factorial =: integers inc product
0 factorial
1
7 factorial
5040
Так то лучше, а то надоело справа налево писать.
+1
!DOCTYPE html>
<html>
<%c++
auto para=@@.get<std::map<std::string,std::string>>("parameters");
%>
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
</head>
<body>
<%view header %>
<%c++ if(para.size()>0){%>
<H1>Parameters</H1>
<table border="1">
<tr>
<th>name</th>
<th>value</th>
</tr>
<%c++ for(auto iter:para){%>
<tr>
<td>{%iter.first%}</td>
<td><%c++ $$<<iter.second;%></td>
</tr>
<%c++}%>
</table>
<%c++ }else{%>
<H1>no parameter</H1>
<%c++}%>
</body>
C++ шаблонизатор
https://github.com/an-tao/drogon/blob/master/examples/simple_example/ListParaView.csp
+2
$currentTask = Tasks::model()->findByPk($currentTask->id);
Yii1. Ищет то, что уже имеет и у меня только 1 вопрос - что в голове у этой ТП?
−1
function writeln($mass){
echo '<pre>';
print_r($mass);
echo '</pre>';
}
ФКУ
0
// int limit - кол-во записей на странице
// int current - текущая страница
// int pages - кол-во страниц
// int count - общее кол-во записей
if (limit > 0) {
pages = count / limit;
if (count % limit > 1) {
pages++;
}
if (current != pages) {
if (current >= 1 && current <= pages) {
current = pages / (current + 1);
} else {
current = 1;
}
}
}
Феерическая реализация постраничника от джуна
−101
жопаembler — гниль