// C++
int count;
cin >> count;
map<int,pair<double,double> > items;
for (int i = 0; i < count; i++)
{
double a, b;
cin >> a >> b;
items.insert(make_pair(i+1,make_pair(a,b));
}
// usage
cout << map[2].first << " " << map[2].second << endl;
double array[3][2]; /* 3 rows, 2 columns */
array[0][0] = 1.2; /* first row, first column */
array[0][1] = 2.4; /* first row, second column */
array[1][0] = 3.5; /* second row, first column */
array[1][1] = 1.2; /* second row, second column */
array[2][0] = 0.4; /* third row, first column */
array[2][1] = 5.6; /* third row, second column */
#include <stdio.h>
int main()
{
FILE *fi;
int i, j, x, z;
int size_arr;
i=0;
fi = fopen("input.txt", "r");
sscanf(line, "%3f2", &size_arr);
double a[size_arr][size_arr];
while (fgets(line,20,fi)!=NULL)
{
for(i=0; i <= size_arr; i++)
for (i=0; i <= size_arr; i++)
a[i][j] = fi;
}
fclose(fi);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0;
int i, j;
int num_arr;
float float_temp;
// Declare the file pointer that we will read from.
FILE* fin;
// Call the fopen function to open the file numbers.txt for reading.
fin = fopen("input.txt", "r");
fscanf(fin, "%d", &num_arr);
double arr[num_arr][num_arr];
for(i=0; i <= num_arr; i++)
for(j=0; j <= num_arr; j++)
{
fscanf(fin, "%lf", &float_temp);
arr[i][j] = float_temp;
}
fclose(fin);
for(i=0; i <= num_arr; i++)
for(j=0; j <= num_arr; j++)
{
printf(" ", arr[i][j]);
}
system("PAUSE");
return 0;
}
int main(void)
{
int sum = 0;
int i, j;
int num_arr;
double float_temp;
FILE* fin;
fin = fopen("input.txt", "r");
fscanf(fin, "%d", &num_arr);
printf("%d\n", num_arr);
double arr[num_arr][2];
for(i=0; i < num_arr; i++)
for(j=0; j < 2; j++)
{
if(feof(fin))
break;
fscanf(fin, "%lf", &float_temp);
arr[i][j] = float_temp;
}
fclose(fin);
for(i=0; i < num_arr; i++)
for(j=0; j < 2; j++)
{
printf("position(%d)(%d) %.1lf \n", i, j, arr[i][j]);
}
system("PAUSE");
return 0;
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
How can my static class become undefined?? | 8 | 49 | |
Graphics | 2 | 28 | |
Cant save 3D | 4 | 20 | |
How to measure current at integrated circuit (IC) power pin using Current Probe ? | 6 | 18 |
Join the community of 500,000 technology professionals and ask your questions.