西工大C语言考试习题.docx
文本预览下载声明
1:2:3#include stdio.h#include stdlib.hint main(){ int a,b,c,d,e,f,g,h,i,k,l,m; for(a=1;a=3;a++) for(b=2;b=6;b++) if(b!=a) for(c=3;c=9;c++) if(c!=bc!=a) for(d=1;d=9;d++) if(d!=cd!=bd!=c) for(e=1;e=9;e++) if(e!=ae!=be!=ce!=d) for(f=1;f=9;f++) if(f!=af!=bf!=cf!=df!=e) for(g=1;g=9;g++) if(g!=ag!=bg!=cg!=dg!=eg!=f) for(h=1;h=9;h++) if(h!=ah!=bh!=ch!=dh!=eh!=fh!=g) for(i=1;i=9;i++){ if(i!=ai!=bi!=ci!=di!=ei!=fi!=gi!=h){ k=a*100+d*10+g; l=b*100+e*10+h; m=c*100+f*10+i; if(l==2*km==3*k) printf(%d %d %d\n,k,l,m);}} return 0;8#include stdio.h#include stdlib.hint fun(int i){ int k; do{ k=i%10; i=i/10; if(k==8) break;}while(i!=0); return k;}int gun(int i){ int s=0; do{ s=s+i%10; i=i/10;}while(i!=0); return s;}int main(){ int N,i; scanf(%d,N); for(i=8;i=N;i++){ if(fun(i)==8||gun(i)==8||i%8==0) printf(%d ,i);} return 0;}8的次数#include stdio.h#include stdlib.hint fun(int i){ int k,t=0; do{ k=i%10; i=i/10; if(k==8) t=t+1;}while(i!=0); return t;}int main(){ int M,N,i,s=0; scanf(%d%d,M,N); for(i=M;i=N;i++) s=s+fun(i); printf(%d,s); return 0;}A*B#include stdio.h#include string.h#include stdlib.hvoid cheng(char a[],char b[]){ int i,j,ca,cb,*s; ca=strlen(a); cb=strlen(b); s=(int *)malloc(sizeof(int)*(ca+cb)); for (i=0;ica+cb;i++) s[i]=0; for (i=0;ica;i++) for (j=0;jcb;j++) s[i+j+1]+=(a[i]-0)*(b[j]-0); for (i=ca+cb-1;i=0;i--) if (s[i]=10) { s[i-1]+=s[i]/10; s[i]%=10; } i=0; while(s[i]==0) i++; for (;ica+cb;i++) printf(%d,s[i]); printf(\n); free
显示全部