Commit d14e786d by mahunt

all

parent e637da5e
Showing with 237 additions and 0 deletions
#include <stdio.h>
#include <string.h>
int main()
{
float orthogonalMatrix[6][6];
float initialVector[6] = {0.3, 0.4, -2, -4.4, 2.2, 3};
memcpy(orthogonalMatrix[0], initialVector, 6*sizeof(float));
float sumOfSquares;
for(int i = 1; i < 6; i++)
{
sumOfSquares = 0;
if(initialVector[i]==0)
{
orthogonalMatrix[i] [i-1]= 1;
}
for(int j = i; j < 6; j++)
{
sumOfSquares += initialVector[j]*initialVector[j];
}
if(sumOfSquares == 0)
{
for(int j = i; j < 6; j++)
{
orthogonalMatrix[j][j] = 1;
}
}
initialVector[i-1] = -1 * sumOfSquares / initialVector[i-1];
memcpy(orthogonalMatrix[i], initialVector, 6 * sizeof(float));
initialVector[i-1] = 0;
}
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
printf("%f,", orthogonalMatrix[i][j]);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int matricesWidth = 0;
int matricesHeight = 0;
int checker = 0;
//Input Matrices Size and Checks for Being Square
while(checker == 0)
{
printf("Please enter a matrices width: ");
scanf("%d", &matricesWidth);
printf("Please enter a matrices height: ");
scanf("%d", &matricesHeight);
if(matricesWidth == matricesHeight)
{
checker = 1;
}
}
int matricesOne[matricesHeight][matricesWidth];
int matricesTwo[matricesHeight][matricesWidth];
int i;
int z;
//Inputs Matrice 1 and 2 Values
for(i = 0; i < matricesHeight; i++)
{
for(z = 0; z < matricesWidth; z++)
{
printf("\nPlease enter a value for Matrices 1 at Row: %d and Column: %d", i, z);
scanf("%d", &matricesOne[i][z]);
printf("\nPlease enter a value for Matrices 2 at Row: %d and Column: %d", i, z);
scanf("%d", &matricesTwo[i][z]);
}
}
//Makes 2D arrays for the subbing and adding
int subtractResult[matricesHeight][matricesWidth];
int additionResult[matricesHeight][matricesWidth];
int matOneMulti = 1;
int matOneTwoMulti = 1;
int matTwoMulti = 1;
int matTwoTwoMulti = 1;
int matOneSum = 0;
int matTwoSum = 0;
int matPos = matricesHeight-1;
int a = 0;
int b = 0;
//Adds and Subtracts the Arrays
for(i = 0; i < matricesHeight; i++)
{
for(z = 0; z < matricesWidth; z++)
{
subtractResult[i][z] = matricesOne[i][z] - matricesTwo[i][z];
additionResult[i][z] = matricesTwo[i][z] + matricesTwo[i][z];
}
//Diagonal Multi
if(a == b)
{
matOneMulti = matOneMulti*matricesOne[a][b];
matOneTwoMulti = matOneTwoMulti*matricesOne[a+matPos][b];
matTwoMulti = matTwoMulti*matricesTwo[a][b];
matTwoTwoMulti = matTwoTwoMulti*matricesTwo[a+matPos][b];
matPos = matPos-matricesHeight/2;
}
a++;
b++;
}
//Diag Multi Cont.
matOneSum = matOneMulti + matOneTwoMulti;
matTwoSum = matTwoMulti + matTwoTwoMulti;
//Prints out the arrays
printf("Array 1 \n");
for(i = 0; i < matricesWidth; i++)
{
for(z = 0; z < matricesHeight; z++)
{
printf("%d, ", matricesOne[i][z]);
}
printf("\n");
}
printf("\n");
printf("Array 2 \n");
for(i = 0; i < matricesWidth; i++)
{
for(z = 0; z < matricesHeight; z++)
{
printf("%d, ", matricesTwo[i][z]);
}
printf("\n");
}
printf("\n");
printf("Subtraction \n");
for(i = 0; i < matricesWidth; i++)
{
for(z = 0; z < matricesHeight; z++)
{
printf("%d, ", subtractResult[i][z]);
}
printf("\n");
}
printf("\n");
printf("Addition \n");
for(i = 0; i < matricesWidth; i++)
{
for(z = 0; z < matricesHeight; z++)
{
printf("%d, ", additionResult[i][z]);
}
printf("\n");
}
printf("\n");
printf("Multiply 1: %d \n", matOneSum);
printf("\n");
printf("Multiply 2: %d \n", matTwoSum);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char name[10][30];
int numDupli = 1;
int i;
int j;
for(i = 1; i <= 10; i++)
{
printf("\nPlease Enter a Name %d: ", i);
scanf("%s", &name[i-1][0]);
printf("\n");
}
for(i = 0; i < 10; i++)
{
strlwr(name[i]);
}
for(i = 0; i < 9; i++)
{
for(j = i; j < 9; j++)
{
if(strcmp(name[i], name[j+1]) == 0)
{
numDupli++;
j = 9;
}
}
}
printf("\n");
printf("%d", numDupli);
}
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