//shit code 80 lvl
void getMessageAndChannel(char*buffer,char*message,char*channel)
{
if(strstr(buffer, "PRIVMSG") != NULL )
{
while(*buffer !='#')*buffer++;
while(*buffer!=' ' && *buffer)
*channel++=*buffer++;
while(*buffer!=':' && *buffer)*buffer++;
while(*buffer!='\n' && *buffer)
*message++=*buffer++;
}///
}
strcpy(szBuffer, sBuffer);
so many questions given you by Hungarian notation
s[strlen(s)] = '\0';
int t;
if ((t > 1) && (t < 2))
{
errorString = errorBuffer;
return -1;
}
int min(int a,int b,int c) //Function to return the minimum.
{
if(a < b)
{
if(a < c)return a;
else if(a > c)return c;
else return a;
}
else if(a > b)
{
if(b < c)return b;
else if(b > c)return c;
else return b;
}
else
{
if(a < c) return a;
else if(a > c) return c;
else return a;
}
}
This kind of things make me hate my work.
int minimum(int a, int b, int c){
int mini =a*b*c;
int iterator=0;
int test[3];
test[0]=a;
test[1]=b;
test[2]=c;
for (iterator=0;iterator<3;iterator++){
if (test[iterator]<mini){
mini=test[iterator];
}
}
return mini;
}
I hope that your 3 numbers aren't larger than 1290!
file = fopen(argv[1], "r");
if (file == NULL){}
exit(EXIT_FAILURE);
Those silly curly braces.
int true = 0;
while (true)
{
//do something
}
true = false
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
...
if (alignEntrySize & 1)
alignEntrySize++;
if (alignEntrySize & 2)
alignEntrySize += 2;
...
// enum - full enumeration of knapsack solutions
// (C) Joshua Knowles
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
FILE *fp; // file pointer for reading the input files
int Capacity; // capacity of the knapsack (total weight that can be stored)
int Nitems; // number of items available
int *item_weights; // vector of item weights
int *item_values; // vector of item profits or values
int *temp_indexes; // list of temporary item indexes for sorting items by value/weight
int QUIET=0; // this can be set to 1 to suppress output
extern void read_knapsack_instance(char *filename);
extern void print_instance();
extern void sort_by_ratio();
extern int check_evaluate_and_print_sol(int *sol, int *total_value, int *total_weight);
void enumerate();
int next_binary(int *str, int Nitems);
int main(int argc, char *argv[])
{
read_knapsack_instance(argv[1]);
print_instance();
enumerate();
return(0);
}
void enumerate()
{
// Do an exhaustive search (aka enumeration) of all possible ways to pack
// the knapsack.
// This is achieved by creating every binary solution vector of length Nitems.
// For each solution vector, its value and weight is calculated.
int i; // item index
int solution[Nitems+1]; // (binary) solution vector representing items packed
int best_solution[Nitems+1]; // (binary) solution vector for best solution found
int best_value; // total value packed in the best solution
double j=0;
int total_value, total_weight; // total value and total weight of current knapsack solution
int infeasible; // 0 means feasible; -1 means infeasible (violates the capacity constraint)
// set the knapsack initially empty
for(i=1;i<=Nitems;i++)
{
solution[i]=0;
}
QUIET=1;
best_value=0;
while(!(next_binary(&solution[1], Nitems)))
{
/* ADD CODE IN HERE TO KEEP TRACK OF FRACTION OF ENUMERATION DONE */
// calculates the value and weight and feasibility:
infeasible=check_evaluate_and_print_sol(solution, &total_value, &total_weight);
/* ADD CODE IN HERE TO KEEP TRACK OF BEST SOLUTION FOUND*/
}
/* ADD CODE TO PRINT OUT BEST SOLUTION */
}
int next_binary(int *str, int Nitems)
{
// Called with a binary string of length Nitems, this
// function adds "1" to the string, e.g. 0001 would turn to 0010.
// If the string overflows, then the function returns 1, else it returns 0.
int i=Nitems-1;
while(i>=0)
{
if(str[i]==1)
{
str[i]=0;
i--;
}
else
{
str[i]=1;
break;
}
}
if(i==-1)
{
return(1);
}
else
{
return(0);
}
}
A genuine UoM lab.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
void run_func(char *map[], char *fnt , char *km , float *x , float *y , int line , int row , int lift );
char *long_met[3][8] = {{"mile","0.621371" , "yard","1093.61" , "fut","3280.84" , "duim","39370.1" } ,
{ "mile" ,"1.60934" , "yard","0.0009144" , "fut","0.0003048" , "duim","0.0000254"},
{"kilometer","1" , "meter","1000" , "stmeter","100000" , "mmeter","1000000" } };
char *amount[3][4] = { { "gallon" , "0.264172" , "quarta" , "1.05669" } ,
{"gallon" , " 3.78541" , "quarta" , "0.946353" },
{"litr" , "1" , "mililitr" , "1000" }};
char *mass[3][8] = { {"eng.tonna","0.984207" , "amer.tonna","1.10231" , "stone","157.473" , "funt","2204.62" } ,
{ "eng.tonna" , "1.01605" , "amer.tonna", "0.907185" , "stone","0.00635029" , "funt","0.000453592"},
{"tonna","1" , "kilogram" , "1000" , "miligram","100000" , "microgram","1000000" }};
char **cp;
char *buf_data;
char *fnt_sys;
char *mtr_sys;
char *word[100];
while(1){
int bg = 0,convert_ch = 3,y = 0, d = 0, numb = 0;
float mn =0 , xm = 0 ;
printf("%s", "enter data for converter: ");
fgets( (char *) word, 99 ,stdin);
buf_data = strtok((char *) word, " ");
if( ! strcmp(buf_data, "funt.sys" ) ){
convert_ch = 0;
}
else if( ! strcmp(buf_data, "metric.sys" ) ){
convert_ch = 1;
}
for( bg = 0 ; buf_data != NULL; buf_data = strtok(NULL, " ") , bg++ ) {
switch(bg){
case 1:
if( !strcmp("long_met" , buf_data ) ){
y = sizeof(*long_met) / sizeof(long_met[0][0]);
d = sizeof(long_met) / sizeof(long_met[0][0]);
cp = &long_met[convert_ch][0] ;
}
else if(!strcmp("amount" , buf_data ) ){
y = sizeof(*amount) / sizeof(amount [0][0]);
d = sizeof(amount) / sizeof(amount[0][0]);
cp = &amount[convert_ch][0] ;
}
else if(!strcmp("mass" , buf_data ) ){
y = sizeof(*mass ) / sizeof(mass[0][0]);
d = sizeof(mass ) / sizeof(mass[0][0]);
cp = &mass[convert_ch][0] ;
}
break;
case 2:
fnt_sys = buf_data;
break;
case 3:
mtr_sys = buf_data;
break;
case 4:
numb = atoi(buf_data);
break;
}
}
if( !y || !d || !cp || convert_ch == 3 || !numb ){
puts("error");
}
else{
run_func( cp, fnt_sys , mtr_sys , &mn , &xm , y , d , convert_ch );
if( !mn || !xm ){
puts("error");
} else{
printf("%f\n" , !convert_ch ? (mn / xm ) * numb : ( mn * xm ) * numb );
}
}
}
return 0;
}
void run_func(char *map[], char *fnt , char *km , float *x , float *y , int line , int row , int lift ){
int m ;
if( ( lift ) ){
row -= line;
}
for( m = 0 ; m <= line ; m++){
if(!strcmp(fnt,map[m])){
*x = atof(map[m + 1] ) ;
break;
}
}
for( m = (row - line) ; m <= row - 1 ; m++){
if( !strcmp( km , map[m] ) ){
*y = atof(map[m + 1 ] );
break;
}
}
}
void destroy_phone(T9obj* ptr_T9Obj){
free(ptr_T9Obj);
}
Such thoughtful name!
if (wiringPiMode == WPI_MODE_PINS)
pin = pinToGpio[pin];
else if (wiringPiMode == WPI_MODE_PHYS)
pin = physToGpio[pin];
else if (wiringPiMode != WPI_MODE_GPIO)
return;
the 3rd condition check throws you right off the train of logic.
double func_atof(char *p){
double integer = 0.0, div = 1.0 , fract = 0.0 , sign = 1.0;
if( *p == 45 ){sign = -1.0, *p++ ; }
while ( isdigit(*p) ) {
integer = ( *p++ ) + (10.0 * integer) - 48.0 ;
}
if(*p == 46 ){
(*p++ ) ;
while ( isdigit(*p) ) {
fract = ( *p++ ) + (10.0 * fract) - 48.0 ;
div *= 10;
}
}
return (integer + fract / div ) * sign ;
}