Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

tekalj / iax0583

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 39e17309 authored 6 years ago by tekalj's avatar tekalj
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

lab5

parent 04f78ce1
Show whitespace changes
Inline Side-by-side
Showing with 122 additions and 0 deletions
  • fifthLabTask1.c
  • fifthLabTask2
  • fifthLabTask2.c
  • fifthLabTask2.o
  • fifthlab
  • fifthlab.c
  • fifthlab.o
fifthLabTask1.c 0 → 100644
View file @ 39e17309
#include <stdio.h>
int main () {
int N;
int i;
int j;
int swap;
printf("Please insert array size\n"); //first part,user inputs N
scanf("%d", &N);
int array[N]; //second part, user inputs i
for (i = 0; i < N; i++){
printf("Please insert a number\n");
scanf("%d", &array[i]);
}
for (i = 0; i < N; i++){
for (j = 0; j < N-1; j++){
if ( array[j] < array[j + 1] ) {
swap = array[j];
array[j] = array[j + 1];
array[j + 1] = swap;
}
}
}
printf("\nElements in array are: ");
for(j = 0; j < N; j++)
{
printf("%d, ", array[j]);
}
return 0;
}
This diff is collapsed. Click to expand it.
fifthLabTask2 0 → 100644
View file @ 39e17309
File added
This diff is collapsed. Click to expand it.
fifthLabTask2.c 0 → 100644
View file @ 39e17309
#include <stdio.h>
#include <math.h>
int main() {
int sk;
double lenght1;
double lenght2;
double lenght;
double angle, x;
int i, j;
int v[4][3] = {{1, 4, 6},
{2, -3, 1},
{3, 5, 0},
{3, 1, -3}
} ;
for (i = 0; i <= 2; i++){
for (j = i+1 ; j <= 3; j++) {
sk = v[i][0] * v[j][0] + v[i][1] * v[j][1] + v[i][2] * v[j][2];
lenght1 = sqrt(v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]);
lenght2 = sqrt(v[j][0] * v[j][0] + v[j][1] * v[j][1] + v[j][2] * v[j][2]);
lenght = lenght1 + lenght2;
angle = sk/lenght;
x = acos(angle);
printf("%lf, ", x);
}
}
return 0;
}
This diff is collapsed. Click to expand it.
fifthLabTask2.o 0 → 100644
View file @ 39e17309
File added
This diff is collapsed. Click to expand it.
fifthlab 0 → 100644
View file @ 39e17309
File added
This diff is collapsed. Click to expand it.
fifthlab.c 0 → 100644
View file @ 39e17309
#include <stdio.h>
int main () {
int N;
int i;
int j;
int swap;
printf("Please insert array size\n"); //first part,user inputs N
scanf("%d", &N);
int array[N]; //second part, user inputs i
for (i = 0; i < N; i++){
printf("Please insert a number\n");
scanf("%d", &array[i]);
}
for (i = 0; i < N; i++){
for (j = 0; j < N-1; j++){
if ( array[j] < array[j + 1] ) {
swap = array[j];
array[j] = array[j + 1];
array[j + 1] = swap;
}
}
}
printf("\nElements in array are: ");
for(j = 0; j < N; j++)
{
printf("%d, ", array[j]);
}
return 0;
}
This diff is collapsed. Click to expand it.
fifthlab.o 0 → 100644
View file @ 39e17309
File added
This diff is collapsed. Click to expand it.
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment