Tuesday 28 June 2011 photo 6/7
![]() ![]() ![]() |
Ma bikes :P
Annons
Geo tag
![](http://dayviews.com/cdn/img/geotag_show.png)
Camera info
Camera Desire HD
Focal length 5 mm
ISO 161
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Anonymous
Thu 30 Jun 2011 20:49
crescenten till höger är det en orion? eller en gammlare modell? :)
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Adam H (Gäst)
Wed 29 Jun 2011 21:13
#include
#include
#include
#define MAXLINES 5000
char *lineptr[MAXLINES];
int readlines(char *lineptr[], int nlines);
void writelines(char *lineptr[], int nlines);
void qsort_p(void *lineptr[], int left, int right, int (*comp)(void *, void *), int reverse);
int numcmp(char *, char *);
int strcmp_nocase(char *, char *);
int main(int argc, char *argv[])
{
int nlines;
int numeric = 0;
int reverse = 0;
int fold = 0;
while (--argc > 0) {
argv++;
if (**argv == '-') {
(*argv)++;
while (**argv != '\0') {
switch(**argv) {
case 'n':
numeric = 1;
break;
case 'r':
reverse = 1;
break;
case 'f':
fold = 1;
break;
}
(*argv)++;
}
}
}
if ((nlines = readlines(lineptr, MAXLINES)) >= 0) {
qsort_p((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? numcmp : (fold ? strcmp_nocase : strcmp)));
writelines(lineptr, nlines);
return 0;
} else {
printf("input too big to sort\n");
return 1;
}
}
void qsort_p(void *v[], int left, int right, int (*comp)(void *, void *), int reverse)
{
int i, last, dir = 1;
void swap(void *v[], int, int);
if (reverse) {
dir *= -1;
}
if (left >= right) {
return;
}
swap(v, left, (left + right) / 2);
last = left;
for (i = left + 1; i <= right; i++) {
if (dir * (*comp)(v[i], v[left]) < 0) {
swap(v, ++last, i);
}
}
swap(v, left, last);
qsort_p(v, left, last - 1, comp, reverse);
qsort_p(v, last + 1, right, comp, reverse);
}
int numcmp(char *s1, char *s2)
{
double v1, v2;
v1 = atof(s1);
v2 = atof(s2);
if (v1 < v2) {
return -1;
} else if (v1 > v2) {
return 1;
} else {
return 0;
}
}
int strcmp_nocase(char *s1, char *s2)
{
char *s1_nocase, *s2_nocase;
s1_nocase = strdup(s1);
s2_nocase = strdup(s2);
tolower(s1_nocase);
tolower(s2_nocase);
return strcmp(s1_nocase, s2_nocase);
}
void swap(void *v[], int i, int j)
{
void *temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
#define MAXLEN 1000 /* max length of any input line */
int getline(char *, int);
char *alloc(int);
/* readlines: read input lines */
int readlines(char *lineptr[], int maxlines)
{
int len, nlines;
char *p, line[MAXLEN];
nlines = 0;
while ((len = getline(line, MAXLEN)) > 0)
if (nlines >= maxlines || (p = alloc(len)) == NULL)
return -1;
else
{
line[len-1] = '\0'; /* delete newline */
strcpy(p, line);
lineptr[nlines++] = p;
}
return nlines;
}
/* writelines: write output lines */
void writelines(char *lineptr[], int nlines)
{
int i;
for (i = 0; i < nlines; i++)
printf("%s\n", lineptr[i]);
}
/* getline: read a line into s, return length */
int getline(char *s, int lim)
{
int c, i;
for (i = 0; i < lim-1 && (c = getchar()) != EOF && c != '\n'; ++i)
s[i] = c;
if (c == '\n')
s[i++] = c;
s[i] = '\0';
return i;
}
#define ALLOCSIZE 10000 /* size of available space */
static char allocbuf[ALLOCSIZE]; /* storage for alloc */
static char *allocp = allocbuf; /* next free position */
char *alloc(int n) /* return pointer to n characters */
{
if (allocbuf + ALLOCSIZE - allocp >= n) /* it fits */
{
allocp += n;
return allocp - n; /* old p */
}
else /* not enough room */
return 0;
}
char *strdup(char *s)
{
char *t;
t = alloc(strlen(s) + 1);
strcpy(t, s);
}
#include
#include
#define MAXLINES 5000
char *lineptr[MAXLINES];
int readlines(char *lineptr[], int nlines);
void writelines(char *lineptr[], int nlines);
void qsort_p(void *lineptr[], int left, int right, int (*comp)(void *, void *), int reverse);
int numcmp(char *, char *);
int strcmp_nocase(char *, char *);
int main(int argc, char *argv[])
{
int nlines;
int numeric = 0;
int reverse = 0;
int fold = 0;
while (--argc > 0) {
argv++;
if (**argv == '-') {
(*argv)++;
while (**argv != '\0') {
switch(**argv) {
case 'n':
numeric = 1;
break;
case 'r':
reverse = 1;
break;
case 'f':
fold = 1;
break;
}
(*argv)++;
}
}
}
if ((nlines = readlines(lineptr, MAXLINES)) >= 0) {
qsort_p((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? numcmp : (fold ? strcmp_nocase : strcmp)));
writelines(lineptr, nlines);
return 0;
} else {
printf("input too big to sort\n");
return 1;
}
}
void qsort_p(void *v[], int left, int right, int (*comp)(void *, void *), int reverse)
{
int i, last, dir = 1;
void swap(void *v[], int, int);
if (reverse) {
dir *= -1;
}
if (left >= right) {
return;
}
swap(v, left, (left + right) / 2);
last = left;
for (i = left + 1; i <= right; i++) {
if (dir * (*comp)(v[i], v[left]) < 0) {
swap(v, ++last, i);
}
}
swap(v, left, last);
qsort_p(v, left, last - 1, comp, reverse);
qsort_p(v, last + 1, right, comp, reverse);
}
int numcmp(char *s1, char *s2)
{
double v1, v2;
v1 = atof(s1);
v2 = atof(s2);
if (v1 < v2) {
return -1;
} else if (v1 > v2) {
return 1;
} else {
return 0;
}
}
int strcmp_nocase(char *s1, char *s2)
{
char *s1_nocase, *s2_nocase;
s1_nocase = strdup(s1);
s2_nocase = strdup(s2);
tolower(s1_nocase);
tolower(s2_nocase);
return strcmp(s1_nocase, s2_nocase);
}
void swap(void *v[], int i, int j)
{
void *temp;
temp = v[i];
v[i] = v[j];
v[j] = temp;
}
#define MAXLEN 1000 /* max length of any input line */
int getline(char *, int);
char *alloc(int);
/* readlines: read input lines */
int readlines(char *lineptr[], int maxlines)
{
int len, nlines;
char *p, line[MAXLEN];
nlines = 0;
while ((len = getline(line, MAXLEN)) > 0)
if (nlines >= maxlines || (p = alloc(len)) == NULL)
return -1;
else
{
line[len-1] = '\0'; /* delete newline */
strcpy(p, line);
lineptr[nlines++] = p;
}
return nlines;
}
/* writelines: write output lines */
void writelines(char *lineptr[], int nlines)
{
int i;
for (i = 0; i < nlines; i++)
printf("%s\n", lineptr[i]);
}
/* getline: read a line into s, return length */
int getline(char *s, int lim)
{
int c, i;
for (i = 0; i < lim-1 && (c = getchar()) != EOF && c != '\n'; ++i)
s[i] = c;
if (c == '\n')
s[i++] = c;
s[i] = '\0';
return i;
}
#define ALLOCSIZE 10000 /* size of available space */
static char allocbuf[ALLOCSIZE]; /* storage for alloc */
static char *allocp = allocbuf; /* next free position */
char *alloc(int n) /* return pointer to n characters */
{
if (allocbuf + ALLOCSIZE - allocp >= n) /* it fits */
{
allocp += n;
return allocp - n; /* old p */
}
else /* not enough room */
return 0;
}
char *strdup(char *s)
{
char *t;
t = alloc(strlen(s) + 1);
strcpy(t, s);
}
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Anonymous
Wed 29 Jun 2011 10:31
diggar dirten asså! :D
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Anonymous
Wed 29 Jun 2011 02:20
Hoppas att du cyklade på båda två samtidigt bara för att!
![](http://cdn07.dayviews.com/cdn/img/default_avatar_M.png)
Anonymous
Wed 29 Jun 2011 00:07
setup på steethojen?
![](http://cdn07.dayviews.com/101/_u6/_u1/_u4/_u6/_u1/u614615/1366072940_m_1.jpg)
Kennie Löfstedt
Wed 29 Jun 2011 13:15
japp:),crescent håller bra faktiskt iaf dom som kostar lite mer:D
34 comments on this photo
Directlink:
http://dayviews.com/x-force/492310003/