Mistři v programování na #hovnokod

Úlohou študenta bolo načítať 3 veľkosti strán trojuholníka, overiť či sa z takýchto strán dá zostrojiť trojuholník a ak áno, vypočítať jeho obvod.

#include <stdio.h>
#include <stdlib.h>

int main()
{   int a,b,c,d;
    printf("zadaj cislo a:\n");
    scanf ("%d",&a);
    printf("zadaj cislo b:\n");
    scanf ("%d",&b);
    printf("zadaj cislo c:\n");
    scanf ("%d",&c);

      if (c=a+b)
    {
           d=a+b+c;
           printf("obvod trojholnika je:%d.",d);
    }
      else
           printf("z tyhto cisel nemoze byt trojuholnik\n");
    return 0;
}

Anonymous,

read it

int main(){
	const double degToRad = 3.14159265358979323846 / 180.00;
	Vertex A,B,C;
	A = init(A);
	B = init(B);
	C = init(C);
	scanf("%lf %lf %lf %lf %lf %lf", &A.x, &A.y, &A.angle, &B.x, &B.y, &B.angle);
	if(inputIsInvalid(A,B)){
		printf("-1\n");
		return 0;
	}
	C.angle = 180.00 - A.angle - B.angle;
	C.side = sqrt(pow(B.x - A.x, 2)+pow(B.y - A.y,2));
	B.side = (sin(B.angle * degToRad) * C.side)/(sin(C.angle * degToRad));
	A.side = (sin(A.angle * degToRad) * C.side)/(sin(C.angle * degToRad));
	double height = B.side * sin(A.angle * degToRad);
	double* x = (double*) malloc(2*sizeof(double));
	double* y = (double*) malloc(2*sizeof(double));
	calculateRootX(A,B,C,x);
	calculateRootY(A,B,C,x,y);
	if(*y > *(y+1)){
		C.x = *x;
		C.y = *y;
	}else{
		C.x = *(x+1);
		C.y = *(y+1);
	}
	printf("%.2lf %.2lf %.2lf\n", height, C.x, C.y);
	return 0;
}

Anonymous,

kdyz ti pada aplikace pri ukonceni a nevis, ze na konci main by mel byt return :D

int main(int argc, char *argv[])
{
	...
	printf("RUN FOREVER!!!\n");
	while(1)
	{
		printf("test app: num  = %d \n", num);
		num++;
		
		sleep(1);
	}
}

Anonymous,

Kolega napísal 3 nekonečné cykly pod semafórom. Vraj mu to ale fungovalo :)

mutex.lock();
std::string text = "";

while(true){
    do{
        for(char c; c = fgetc(file); text+=c);
    } while(c != '\n');

    if(text != "")
        break;
}

mutex.unlock();

Anonymous,

Ja ani neviem co k tomu dodat......

#if defined (__APPLE__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
    double matrix[4][4] = {0.0};
#if defined (__APPLE__)
#pragma clang diagnostic pop
#endif

Anonymous,