473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Converting C algorithm for use in a c# application

Would appreciate assistance with this data array definition:
Expand|Select|Wrap|Line Numbers
  1. struct sun_con
  2.    {
  3.    double l;
  4.    double r;
  5.    double alpha;
  6.    double nu;
  7.    };
  8.  
  9.    static const struct sun_con con[50] =
  10.       {{403406.0,      0.0, 4.721964,     1.621043},
  11.        {195207.0, -97597.0, 5.937458, 62830.348067},
  12.        {119433.0, -59715.0, 1.115589, 62830.821524},
  13.        {112392.0, -56188.0, 5.781616, 62829.634302},
  14.        {  3891.0,  -1556.0, 5.5474  , 125660.5691 },
  15.        {  2819.0,  -1126.0, 1.5120  , 125660.9845 },
  16.         more data rows
  17.        }
  18.       for (i = 0; i < 50; i++)
  19.    {
  20.       arg = con[i].alpha + con[i].nu * u;
  21.       sum_lon += con[i].l * sin (arg);
  22.       sum_r += con[i].r * cos (arg);
  23.    }
Jul 1 '14 #1
1 1397
horace1
1,510 Expert 1GB
you could create a sun_con constructor and then initialise the array so (assuming a console application)
Expand|Select|Wrap|Line Numbers
  1.  struct sun_con
  2. {
  3. public double l;
  4. public double r;
  5. public double alpha;
  6. public double nu;
  7.      // constructor
  8.      public sun_con(double _l, double _r, double _alpha, double _nu)
  9.      {l=_l; r=_r; alpha=_alpha; nu=_nu; }
  10. };
  11.  
  12. static  
  13.  sun_con[] con = new sun_con[]{
  14.     new sun_con(403406.0, 0.0, 4.721964, 1.621043),
  15.     new sun_con(195207.0, -97597.0, 5.937458, 62830.348067),
  16.     new sun_con(119433.0, -59715.0, 1.115589, 62830.821524),
  17.     new sun_con(112392.0, -56188.0, 5.781616, 62829.634302),
  18.     new sun_con( 3891.0, -1556.0, 5.5474 , 125660.5691 ),
  19.     new sun_con(2819.0, -1126.0, 1.5120 , 125660.9845 ),
  20. //more data rows
  21. };
  22.  
  23. static void Main(string[] args)
  24.     {
  25.     for (int i = 0; i < 6; i++)
  26.         {
  27.         Console.WriteLine(" {0} ",con[i].l);
  28.         //double arg = con[i].alpha + con[i].nu * u;
  29.         //double sum_lon += con[i].l * sin (arg);
  30.         //double sum_r += con[i].r * cos (arg);
  31.         }        
  32.     }
  33.  
prints on the console
Expand|Select|Wrap|Line Numbers
  1. 403406 
  2.  195207 
  3.  119433 
  4.  112392 
  5.  3891 
  6.  2819 
Jul 5 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Duncan Welch | last post by:
Good morning, I have a classic ASP app that I'm converting to .NET. In the existing app when accessing infrequntly changed data, it reads a database once a day, and saves the results in an...
9
by: sarah.clough | last post by:
Hi all, I have a project that was created in Visual Studio 6 using VB. Is it possible to open this project in Visual Studio .NET and automatically convert it into .NET, or do I have to manually...
2
by: asadikhan | last post by:
I have written a console application that clears out some folders. I want this application to run as a Windows Service (not a scheduled task). What is the easiest way to convert this console...
17
by: > Adrian | last post by:
I have converted a number of applications to enable them to work together on a network. I have been led to believe that I can do this as follows: FileStream fs = new FileStream(some code); while...
1
by: mukeshsrivastav | last post by:
dear all Is this possible to convert an application of vb6 to asp.net application . actually i design one application in vb6 now i want to use this over internet. show needed to be converted to...
6
by: > Adrian | last post by:
An application I wrote installs ok on W98 and XP. When installed it asks for Framework 1.1. When the application is installed on Vista and Framework 1.1 is made available, the application installs...
2
by: Ronny | last post by:
I have a standard C# windows application with one form and some logic around it. I need to onvert this exe into a dll class library and use it's functionality from another exe. Is there in easy...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.