Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
DÚ 2
//clang 6.0.0 #include <stdio.h> #include <math.h> #include <stdlib.h> size_t n; float *VektPtr; float d; int velikost(float *aVektPtr, float *VelikostPtr, size_t aPocet); int main(void) { //a printf("Zadejte pocet prvku vektoru\n"); scanf("%zu", &n); //b VektPtr = malloc(n * sizeof (float)); if(VektPtr == NULL) { return 1; } //c printf("zadej pocet prvku:\n"); for(int i = 0; i < n; i ++) scanf("%f", &VektPtr[i]); //3 int ret; ret = velikost(VektPtr, &d, n); if(ret == 0) { printf("d=%f", d); } //4 free (VektPtr); return 0; } int velikost(float *aVektPtr, float *VelikostPtr, size_t aPocet) { int ret = 0; float mocnina = 0; if(aPocet == 0) { ret = -1; } for(int i = 0; i < aPocet; i++) { mocnina += (aVektPtr[i] * aVektPtr[i]); } *VelikostPtr = sqrt(mocnina); return ret; }
run
|
edit
|
history
|
help
0
UDP - Male/Velke pismena
lab7
Cviceni 7 1 uloha ++upper,isupper
Herout (67) - 8
definice funkce
Cuadrado asteriscos solido
Vzdalenost makro inline
Pointer_Indirectare_N
fun kce
Teylor