资源预览内容
第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
亲,该文档总共7页全部预览完了,如果喜欢就下载吧!
资源描述
1 1、选择题、选择题(1)A(2)C(3)A(4)B(5)B(6)D(7)D(8)B(9)D(10)B2 2、填空题、填空题(1)a=10,b=20 a=20,b=10(2)*pp=603 3、程序设计题、程序设计题(1)#includechar *month_name(int n);void main()int n;printf(“nPlease enter 1 integer:“);scanf(“%d“,printf(“%d month :%sn“,n,month_name(n);char *month_name(int n)static char*name=“illegal month“, “Jan“,“Feb“,“Mar“,“Apr“,“May“,“Jun“, “July“,“Aug“,“Sept“,“Oct“,“Nov“,“Dec“;return (n12)?name0:namen);(2)#include#define N 10sort(int data)int i,j,min_a,temp;for(i=0;ivoid reverse(char *c);void main()char str80;puts(“Please enter 1 stringn“);gets(str);reverse(str) ;puts(“After reversedn“);puts(str);void reverse(char *c)char *p,*q,temp;int size=0;for(p=c;*p!=0;p+)size+;size=size/2;for(q=c,p-;q#includevoid sort(char *keyword,int size);void print(char *keyword,int size)void main()char *keyword=“if“,“else“,“case“,“switch“,“do“,“whlie“,“for“,“break“,“continue“;sort(keyword,9);print(keyword,9);void sort(char *keyword,int size)int i,j,min_location;char *temp;for(i=0;i0)min_location=j;if(min_location!=i)temp=keywordi;keywordi=keywordmin_location;keywordmin_location=temp;void print(char *keyword,int size)int i;for(i=0;i void fun_char(char str1,char str2,char str3); void main() char str180,str280,str380,c,i;printf(“nPlease enter 2 string:“);scanf(“%s%s“,str1,str2); fun_char(str1,str2,str3);printf(“Third string is %s.“,str3); void fun_char(char *str1,char *str2,char *str3) int i,j,k,flag;i=0,k=0;while(*(str1+i)!=0)j=0;flag=1;while(*(str2+j)!=0j+;if(flag)*(str3+k)=*(str1+i); k+;i+;*(str3+k)=0; (6) #include int count_word(char *str); void main() char str180,c,res;puts(“nPlease enter a string:“);gets(str1);printf(“There are %d words in this sentence“,count_word(str1); int count_word(char *str) int count ,flag;char *p;count=0;flag=0;p=str;while(*p!=0)if(*p= )flag=0;else if(flag=0)flag=1;count+;p+;return count; (7) #include #include char *encrypt(char *string); char *decrypt(char *string); main() char item80;char *point;char *pEncrypted;char *pDecrype;printf(“Please enter the string need to encrypt:n“);gets(item);point=item;pEncrypted=encrypt(point);printf(“nThe string after encrypted is:n%sn“,pEncrypted);pDecrype=decrypt(pEncrypted);printf(“nThe string after decrypted is:n%sn“,pDecrype);free(pEncrypted);free(pDecrype); char *encrypt(char *string) char *q,*t;q=(char *)malloc(sizeof(char)*80);if(!q)printf(“No place to malloc!“);return 0;t=q;while(*string!=0)*q=*string-2;string+;q+;*q=0;return t; char *decrypt(char *string) char *q,*t;q=(char *)malloc(sizeof(char)*80);if(!q)printf(“No place to malloc!“);return 0; t=q;while(*string!=0)*q=*string+2;string+;q+;*q=0;return t;
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号