SAE24_2022/ex1/scripts/ex1-2.sce

50 lines
2.2 KiB
Scilab

data = csvRead("data.csv");
surfaceAfrique = sum(data(1:57, 2)* 1000);
populationAfrique = sum(data(1:57, 3)* 1000000);
densiteAfrique = populationAfrique / surfaceAfrique;
surfaceAmeriqueDuNord = sum(data(58:86, 2)* 1000);
populationAmeriqueDuNord = sum(data(58:86, 3)* 1000000);
densiteAmeriqueDuNord = populationAmeriqueDuNord / surfaceAmeriqueDuNord;
surfaceAmeriqueDuSud = sum(data(87:99, 2)* 1000);
populationAmeriqueDuSud = sum(data(87:99, 3)* 1000000);
densiteAmeriqueDuSud = populationAmeriqueDuSud / surfaceAmeriqueDuSud;
surfaceAsie = sum(data(100:150, 2)* 1000);
populationAsie = sum(data(100:150, 3)* 1000000);
densiteAsie = populationAsie / surfaceAsie;
surfaceEurope = sum(data(151:193, 2)* 1000);
populationEurope = sum(data(151:193, 3)* 1000000);
densiteEurope = populationEurope / surfaceEurope;
surfaceOceanie = sum(data(194:207, 2)* 1000);
populationOceanie = sum(data(194:207, 3)* 1000000);
densiteOceanie = populationOceanie / surfaceOceanie;
mprintf("Surface terrestre :\n");
mprintf("\t• Afrique : %d km²\n", surfaceAfrique);
mprintf("\t• Amérique du nord : %d km²\n", surfaceAmeriqueDuNord);
mprintf("\t• Amérique du sud : %d km²\n", surfaceAmeriqueDuSud);
mprintf("\t• Asie : %d km²\n", surfaceAsie);
mprintf("\t• Europe : %d km²\n", surfaceEurope);
mprintf("\t• Océanie : %d km²\n", surfaceOceanie);
mprintf("Population :\n");
mprintf("\t• Afrique : %d habitants\n", populationAfrique);
mprintf("\t• Amérique du nord : %d habitants\n", populationAmeriqueDuNord);
mprintf("\t• Amérique du sud : %d habitants\n", populationAmeriqueDuSud);
mprintf("\t• Asie : %d habitants\n", populationAsie);
mprintf("\t• Europe : %d habitants\n", populationEurope);
mprintf("\t• Océanie : %d habitants\n", populationOceanie);
mprintf("Densité moyenne :\n");
mprintf("\t• Afrique : %.2f habitants/km²\n", densiteAfrique);
mprintf("\t• Amérique du nord : %.2f habitants/km²\n", densiteAmeriqueDuNord);
mprintf("\t• Amérique du sud : %.2f habitants/km²\n", densiteAmeriqueDuSud);
mprintf("\t• Asie : %.2f habitants/km²\n", densiteAsie);
mprintf("\t• Europe : %.2f habitants/km²\n", densiteEurope);
mprintf("\t• Océanie : %.2f habitants/km²\n", densiteOceanie);