Skip to content

Instantly share code, notes, and snippets.

@javascripter
Forked from anonymous/gist:344739
Created March 26, 2010 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javascripter/344974 to your computer and use it in GitHub Desktop.
Save javascripter/344974 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(void) {
int x, y;
for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {
printf("%d x %d = %d\n", x, y, x * y);
}
}
return 0;
}
#include <stdio.h>
int main(void)
{
int i;
int j;/* int i, jでまとめて宣言できる。この場合x,yとしたほうがわかりやすいかも */
for(i=1; i<=5; i=i+1){ /* i=i+1はi++か++iに */
for(j=1; j<=5; j=j+1){/* j=j+1も同様にj++か++j */
/* printfのインデントが足りない */
printf("%d x %d = %d\n",i,j,(i*j));/* (i*j)は単にi*jで良い */
}
return 0; /* インデントがおかしいと場所まちがえる、returnはmainの最後 */
} /* ブレースの位置おかしいよ! */
/* ここでreturn 0;する */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment