echo "hello world"
#include <stdio.h> // かけ算の表を出力するプログラム int main(int argc, char *argv[]) { printf(" 1 2 3 4 5 6 7 8 9\n" " 2 4 6 8 10 12 14 16 18\n" " 3 6 9 12 15 18 21 24 27\n" " 4 8 12 16 20 24 28 32 36\n" " 5 10 15 20 25 30 35 40 45\n" " 6 12 18 24 30 36 42 48 54\n" " 7 14 21 28 35 42 49 56 63\n" " 8 16 24 32 40 48 56 64 72\n" " 9 18 27 36 45 54 63 72 81\n"); return 0; }
#include <stdio.h> void main(void) { printf("hello world.\n"); }
% gcc -Wall -Werror hello.c hello.c:3: 警告: return type of 'main' is not `int' %
#include<stdio.h> main(){ printf("hello world\n"); }
#include<stdio.h> main() { printf("hello world!\n"); }
#include <stdio.h> int main(void) { printf("\"hello world\"\n"); return 0; }
#include <iostream> using namespace std; int main() { cout << "Hello, world!" << endl; return 0; }
#include<stdio.h> int main(){ printf("hello world\n"); }
#include <stdio.h> // 9x9 のかけ算の表を出力するプログラム int main(int argc, char *argv[]) { for (int y = 1; y <= 9; ++y) { for (int x = 1; x <= 9; ++x) { printf("%3d ", x * y); } printf("\n"); } return 0; }
#include<stdio.h> #include<math.h> int main(){ int x,y; printf(" y 0 1 2 3 4 5 6 7 8 9\nx\n"); for(x=0;x<10;x++){ printf("%d ",x); for(y=0;y<10;y++){ printf("%2d ",x*y); } printf("\n"); } }
#include <iostream> using namespace std; int main() { // draw header cout << " "; for(int i = 1; i < 10; i++){ cout << "|"; cout.width(2); cout << i; } cout << endl; cout << "-----------------------------" << endl; // draw contents for(int i = 1; i < 10; i++){ cout.width(2); cout << i; for(int j = 1; j < 10; j++){ cout << "|"; cout.width(2); cout << i * j; } cout << endl; cout << "-----------------------------" << endl; } return 0; }
#include <stdio.h> int main() { int i, j; for(i = 1; i < 10; i++) { for(j = 1; j < 10; j++) { printf("%d*%d=%d ", i, j, i*j); } printf("\n"); } return 0; }
#include<stdio.h> main() { char i,m; for(i=1;i<10;i++){ printf("%dの段",i); for(m=1;m<10;m++){ printf("%3d|",i*m); } printf("\n"); } }
#include<stdio.h> main(){ int i,j; int n=9; for(i=1;i<=n;i++) printf("\t%d",i); printf("\n"); for(i=1;i<=n;i++) printf("\t-----"); printf("\n"); for(j=1;j<=n;j++){ printf("%d :",j); for(i=1;i<=n;i++) printf("\t%d",j*i); printf("\n"); } }