标签:else char acp asa ++ amp lse float 语言
第七题
#include <stdio.h> void splitfloat( float x, int *intpart, float *fracpart ); #include "stdio.h" void delnum(char *s); int main () { char item[80]; gets(item); delnum(item); printf("%s\n",item); return 0; } void delnum(char *s) { int i=0,j=0; while(*(s+i)!=‘\0‘) {if(!(*(s+i)<=‘9‘&&*(s+i)>=‘0‘)) {*(s+j)=*(s+i); j++;} i++;} *(s+j)=‘\0‘; }
第八题
#include<stdio.h> int fun(char *str,char *substr); int main() { char str[81]="asdasasdfgasdaszx67asdmklo",substr[4]="asd"; int n; n=fun(str,substr); printf("n=%d\n",n); return 0; } int fun(char *str,char *substr) { int i,j,k,num=0; for(i=0;*(str+i);i++) for(j=i,k=0;*(substr+k)==*(str+j);k++,j++) if(*(substr+k+1)==‘\0‘) { num++; break; } return(num); }
第九题
#include <stdio.h> int fun(char *s,int num); int main() { char s[10]; gets(s); fun(s,7); printf("%s",s); return 0; } int fun(char *s,int num){ int i,j,k,temp; for(i=1;i<num-2;i++) { k=i; for(j=i+1;j<num-1;j++) { if(s[k]<s[j]) { k=j; } } if(k!=i) { temp=s[i];s[i]=s[k];s[k]=temp; } } return 0; }
7—1
#include <stdio.h> int main() { int N,grade,k,i=1; float average,max,min,sum=0.0; float maxy(float x,float y); float miny(float x,float y); scanf("%d",&N); for(k=0;k<N;k++) { scanf("%d",&grade); sum=sum+grade; if (i==1) { max=grade; min=grade; i--; } max=maxy(max,grade); min=miny(min,grade); } average=sum/N; printf("average = %.2f\nmax = %.2f\nmin = %.2f",average,max,min); return 0; } float maxy(float x,float y) { float z; if(x>y) z=x; else z=y; return(z); } float miny(float x,float y) { float z; if(x<y) z=x; else z=y; return(z); }
标签:else char acp asa ++ amp lse float 语言
原文地址:https://www.cnblogs.com/aytw/p/8746678.html