どちらのプログラムが重いですか?
Posted: 2015年8月03日(月) 19:05
1と2のどちらのプログラムが重いか教えてください。また、その見分け方なども知りたいです。
ちなみに、このような内容の薄いプログラムは重いも軽いもあまりないですか??なければ、こっちで書けた方がいいなどというのもあれば教えてください。説明の仕方が下手ですみません(^^;)
ちなみに、このような内容の薄いプログラムは重いも軽いもあまりないですか??なければ、こっちで書けた方がいいなどというのもあれば教えてください。説明の仕方が下手ですみません(^^;)
//その1
#include <stdio.h>
int main()
{
int count1;
int count2;
int ary[3][3] = {
1 , 5 , 10 ,
50 , 100 , 500 ,
1000 , 5000 , 10000
};
for(count1=0; count1<3; count1++){
for(count2=0; count2<3; count2++){
printf("ary[%d][%d] = %d\n", count1, count2, ary[count1][count2]);
}
}
return 0;
}
//その2
#include <stdio.h>
int main()
{
int count1 = 0;
int count2 = 0;
int ary[3][3] = {
1 , 5 , 10 ,
50 , 100 , 500 ,
1000 , 5000 , 10000
};
while(1) {
printf("ary[%d][%d] = %d\n" , count1 , count2 , ary[count1][count2]);
count2++;
if (count2 == 3) {
count1++;
count2 = 0;
}
if (count1 == 3) break;
}
return 0;
}