Created
May 7, 2012 23:45
-
-
Save aleksmk/2631479 to your computer and use it in GitHub Desktop.
Random C code for a physics task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
float B(float I) { | |
float B=0; | |
float u0 = 0.000001256; | |
float C = 0.71554; | |
B = u0 * C * (132/0.1475) * I; | |
return B; | |
} | |
float BR(float B, float R) { | |
return B * R; | |
} | |
float em(float U, float BR) { | |
return (2*U) / (BR*BR); | |
} | |
int main() { | |
float R1[10][2] = { | |
{180, 1.08}, | |
{200, 1.14}, | |
{220, 1.22}, | |
{240, 1.28}, | |
{260, 1.34}, | |
{280, 1.40}, | |
{300, 1.46}, | |
{320, 1.50}, | |
{340, 1.54}, | |
{360, 1.60} | |
}; | |
float R2[10][2] = { | |
{180, 1.40}, | |
{200, 1.46}, | |
{220, 1.56}, | |
{240, 1.62}, | |
{260, 1.68}, | |
{280, 1.76}, | |
{300, 1.82}, | |
{320, 1.90}, | |
{340, 1.96}, | |
{360, 2.00} | |
}; | |
float r1 = 0.05; | |
float r2 = 0.04; | |
for(int i=0; i<10; i++) { | |
printf("%f\t%f\t%f\t%f\t%f\n", R1[i][0], R1[i][1], B(R1[i][1]), BR(B(R1[i][1]), r1), em(R1[i][0], BR(B(R1[i][1]), r1))); | |
} | |
printf("\n\n"); | |
for(int i=0; i<10; i++) { | |
printf("%f\t%f\t%f\t%f\t%f\n", R2[i][0], R2[i][1], B(R2[i][1]), BR(B(R2[i][1]), r2), em(R2[i][0], BR(B(R2[i][1]), r2))); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment