//#include <stdio.h> //main() //{ // float c, f; // float lower, upper, step; // lower = -17.8; // upper = 148.9; // step = 11.1; // c = lower; // while(c <= upper) // { // f = (9 * c) / 5 + 32; // printf("%6.2f /t %3.0f/n",c,f); // c += step; // } //} //#include "stdio.h" //#define LOWER 200 //#define UPPER 300 //#define STEP 20 //main() //{ // int fahr; // for(fahr = UPPER; fahr >= LOWER; fahr -= STEP) // { // printf("%3d /t %6.2f/n", fahr, 5.0* (fahr - 32) / 9.0); // } //} //#include <stdio.h> //main() //{ // int c; // int h = (c = getchar()) != EOF; // if(h == 1) // { // printf("%d/n",h); // while((c = getchar()) != EOF) // putchar(c); // } // printf("EOF = %d/n",EOF); //} //#include <stdio.h> //main() //{ // int count = 0; // int c; // while((c=getchar())!=EOF) // count++; // printf("There are %d charactors/n",count); //} //#include <stdio.h> //main() //{ // double count; // int c, cl=0; // for(count = 0; (c = getchar())!= EOF; ++count) // { // if(c == '/n') // ++cl; // } // printf("There are %f charactors/n",count); // printf("There are %d lines/n",cl); //} //#include <stdio.h> //int main() //{ // int c, Ept=0, Tab=0, Ent=0; // while((c = getchar())!=EOF) // { // switch(c) // { // case ' ': // ++Ept; // break; // case '/t': // ++Tab; // break; // case '/n': // ++Ent; // break; // } // } // printf("There are %d empty in all/n",Ept); // printf("There are %d tab in all/n",Tab); // printf("There are %d lines in all/n",Ent); // return 0; //} //#include <stdio.h> //main() //{ // int c = 0; // c = getchar(); // putchar(c); // printf("/nit is %d/n",c); //} //#include <stdio.h> //#define IN 1 //#define OUT 0 //main() //{ // int c,nl,nw,nc,flag; // flag = OUT; // nl=nw=nc=0; // while((c=getchar())!=EOF) // { // ++nc; // if(c=='/n') // ++nl; // if(c==' '||c=='/n'||c=='/t') // flag = OUT; // else if(flag == OUT) // { // flag = IN; // ++nw; // } // } // printf("%d %d %d/n",nc,nl,nw); //} //#include <stdio.h> //main() //{ // int c, i, nwhite, nother; // int ndigit[10]; // nwhite = nother = 0; // for(i=0;i<10;++i) // ndigit[i]=0; // while((c=getchar())!=EOF) // { // if(c>='0'&&c<='9') // ++ndigit[c-'0']; // else if(c==' '||c=='/t'||c=='/n') // ++nwhite; // else // ++nother; // } // printf("digits = "); // for(i=0;i<10;i++) // printf(" %d",ndigit[i]); // printf(", white space = %d, other = %d/n",nwhite,nother); //} //#include <stdio.h> //main() //{ // int c; // char a = '0'; // c = a; // printf("%d/n",a); //} #include <stdio.h> #include <assert.h> long power(int m,int n) { long result = 1; assert((m!=0)&&(m!=1)); if(n!=0) { int i; //注意,在for循环中变量i的类型定义,C中与C#有明显的差别。 //必须在循环之外定义变量的类型,而不能写为for(int i=1;i<n;i++) for(i=1; i<=n; ++i) { result*=m; } return result; } else return result; } main() { long test; test = power(1,5); printf("%d/n",test); }