#include <stdio.h>//使用define定义常量#define TR 4int main(){ // int int a=0; // double double b=1.3;//双精度浮点型..小数点后的位数多一点 //PRintf("%f/n",b); // .1 只保留一位小数 //printf("%.1f/n",b); short c=4; //printf("%f/n",c); long d=5.3; float e=3; //没有double后面的小数点多 char f='t'; // 以整形的输出,会输出asc码.. //printf("%d/n",f); // 以字符的形式输出 //printf("%c/n",f); //printf("%d",b); //输入函数. 赋值给a,取地址符号 & //scanf("%d",&a); //printf("%d/n",a); // unsigned 关键字无符号. unsigned int p=-1; //printf("%u",p); // ------------字符串--------- //输入字符串并且打印 char str[]="啦啦啦"; //scanf("%s",&str); //printf("%s/n",str); // -----------常量 ------------- // 使用const 定义 const int cl=4; const double dl=5.5; // 也可使用 #define见头部示范 a=cl*TR; printf("%d",a); return 0;}#include <stdio.h>int main(){ // 测试下这个运算.. double a=0; a++; // 还可以这样玩的.. int b=0; b=(1,2,6); // 会输出6 //printf("%d",b); //-----循环------- // 1 while 循环 int i=0; while(i<100){ i++; //printf("%d,",i); } // do...while int j=0; do{ //printf("%d,",j); j++; }while(j<100); // for 感觉这里和java有点出入.. printf("----------/n"); // ---------c int q=0; for(q;q<100;q++){ //printf("%d,",q); } printf("----------/n"); // if判断以及 关系运算符 if(1==1 || 2==3){ printf("go if/n"); } int e=4; if(e>4){ printf(">4"); }else if(e>3){ printf(">6"); }else{ printf("ohter"); } printf("------switch----/n"); // switch 判断 e=1; gotot: switch(e){ case 1: printf("1"); break; default: printf("ohter"); break; } printf("/n------goto----/n"); // goto 执行到这里,返回过去执行[gotot]这个标志位 //goto gotot; printf("/n------char----/n"); // 输入一个字符 getchar(); //输出一个字符 putchar(c); // 输入后即时进入下一行代码 getch(); char s; //s=getchar(); //printf("%c",s); //putchar(s); //s=getch(); //putchar(s); //printf("%c",s); return 0;}
新闻热点
疑难解答