Jeden "VEARY serious problem with stack overflow error" na StackOverflow :-D
int isEven(long long number) { if (number > 1) { return isEven(number - 2); } if (number == 1) { return false; } return true; }
Jeden "VEARY serious problem with stack overflow error" na StackOverflow :-D
int isEven(long long number) { if (number > 1) { return isEven(number - 2); } if (number == 1) { return false; } return true; }
Jak se na jedne nejmenovane vysoke skole v Brne zjistuje datum v C++
// to add actual year of generated file time_t timeTmp = time(NULL); struct tm *actualTime = localtime(&timeTmp); templates["year"] = actualTime->tm_year + 1900;
bool invalidParams = false; //... if(!invalidParams) invalidParams = true;
Ú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; }
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; }