6.16 编程练习
3.
#include <stdio.h> int main(void)// { const ROW=6; for(int row=0;row<ROW;row++) { char ch ='F'; for(int list=0;list<=row;list++) { printf("%c",ch); ch--; } printf("\n"); } return 0; }
4.
#include <stdio.h> int main(void)// { const ROW=6; for(int row=0;row<ROW;row++) { char ch ='A'+row; for(int list=0;list<=row;list++) { ch+=list; printf("%c",ch); } printf("\n"); } return 0; }
5.
#include <stdio.h> int main(void)// { const ROW=6; for(int row=0;row<ROW;row++) { for(int list=0;list<=ROW-row;list++) { printf(" "); } char ch ='A'; for(int list=0;list<=row;list++) { printf("%c",ch); ch++; } ch ='A'+row; for(int list=0;list<row;list++) { ch--; printf("%c",ch); } printf("\n"); } return 0; }
6.pow()输出为double类型
#include <stdio.h> #include <math.h> int main(void)// { int upper=0; int lower=0; printf("please enter the from upper and lower limits"); scanf("%d%d",&upper,&lower); int ROW=upper; for(int row=lower;row<ROW;row++) { printf("%d,%.0f,%.0f\n",row,pow(2,2),pow(row,3)); } return 0; }
7.
#include <stdio.h> #include <string.h> int main(void)// { char ch[20]; printf("please enter a word\n"); while(scanf("%s",ch)==1) { for(int list=0;list<strlen(ch);list++) { printf("%c",ch[strlen(ch)-list-1]); } printf("\n"); printf("please enter a word\n"); } return 0; }
8.
#include <stdio.h> #include <math.h> int main(void)// { float a=0; float b=0; printf("please enter two floating point number\n"); while(scanf("%f%f",&a,&b)==2) { printf("%f\n",(a-b)/(a*b)); printf("please enter two floating point number\n"); } return 0; }
扫描二维码关注公众号,回复:
9147914 查看本文章