第六次CH1005#include<stdio.h>int main(){int i,a[500]={0},n,*p,j=0,k=0;scanf("%d",&n);for(i=0;i<n;i++)a[i]=i+1;p=a;while(j!=n-1){ if(*p!=0) k++;if(k==3) *p=0,j++,k=0;p++;if(p==a+n) p=a;}for(i=0;i<n;i++)if(a[i]!=0) printf("%d\n",a[i]);return 0;}CH1007{ int n;char a[500],b[500]={'\0'},*p1,*p2;gets(a);scanf("%d",&n);p1=a;p2=b;for(p1=p1+n;*p1!='\0';p1++,p2++) *p2=*p1;puts(b);return 0;}#include<stdio.h>#include<string.h>int main(){char str1[50],str2[20];int m,length;gets(str1);scanf("%d",&m);if((strlen(str1)-m+1)>=20){printf("ERROR\n");}else{for(int i=m;str1[i]!='\0';i++){str2[i-m]=str1[i];}str2[i-m]='\0';printf("%s\n",str2);}return 0;}CH1011#include<stdio.h>{char a[10][10],*p;int i;void paixu(char a[10][10]);for(i=0;i<10;i++)scanf("%s",a[i]);paixu(a);for(i=0;i<10;i++)if(i) printf(" %s",a[i]);else printf("%s",a[i]);printf("\n");return 0;}void paixu(char a[10][10]){ int i,j;char b[10];for(i=0;i<10;i++)for(j=i+1;j<10;j++)if(strcmp(a[i],a[j])>0) strcpy(b,a[i]),strcpy(a[i],a[j]),strcpy(a[j],b); }#include<stdio.h>#include<string.h>int main(){char str[10][10];char string[10];for(int i=0;i<=9;i++){scanf("%s",str[i]);}for(int j=0;j<=9;j++)for(int k=j+1;k<=9;k++){if(strcmp(str[j],str[k])>0){strcpy(string,str[j]);strcpy(str[j],str[k]);strcpy(str[k],string);}}for(i=0;i<=9;i++){printf("%s ",str[i]);}return 0;}CH1016#include<stdio.h>int main(){char str[1000],*p=str;int a[1000],i=0,k=0;gets(str);while(*p){if(*p>='0' && *p<='9'){a[i]=(*p-48);k++;i++;p++;while(*p && *p>='0' && *p<='9'){a[i]=(*p-48);i++;p++;}a[i]=10;i++;}if(!(*p)) break;p++;}printf("num=%d\n",k);for(k=0;k<i-1;k++){a[k]==10?printf(" "):printf("%d",a[k]);}printf("\n");return 0;}#include<stdio.h>#include<string.h>int main(){char str[1000],string[20];int a[1000],num=0,count=0,t=1;gets(str);for(int j=0;;j++){if(str[j]==0){if(num!=0){a[count-1]=0;for(int k=num;k>0;k--){a[count-1]=a[count-1]*10+(str[j-k]-48);}}break;}else{if(str[j]<'0'||str[j]>'9'){if(num!=0){a[count-1]=0;for(int k=num;k>0;k--){//printf("%c",str[j-k]);a[count-1]=a[count-1]*10+(str[j-k]-48);}}// printf("\n");num=0;}else{if(num==0){count++;}num++;}}printf("num=%d\n",count);for(int i=0;i<count;i++){printf("%d ",a[i]);}printf("\n");return 0;}T1004#include<stdio.h>int main(){ char a[100],ch,*p;int i;gets(a);scanf("%c%d",&ch,&i);p=a+i;for(;*p!='\0';p++);*(p+1)='\0';for(;p>a+i;p--)*p=*(p-1);*p=ch;puts(a);return 0;}#include<stdio.h>#include<string.h>int main()char str[80];gets(str);char a,temp;int b,length;scanf("%c%d",&a,&b);length=strlen(str);for(int i=length;i>=b;i--){str[i+1]=str[i];}str[b]=a;printf("%s\n",str);return 0;}T1006#include<stdio.h>int main(){void strencode(char *s);char a[300];gets(a);strencode(a);puts(a);return 0;}void strencode(char *s){ for(;*s!='\0';s++)if(*s>='a' && *s<='z') *s=*s-3;else if(*s>='A' && *s<='Z') *s=*s+3; }#include<stdio.h>#include<string.h>char* strencode(char *str){for(int i=0;str[i]!='\0';i++){if(str[i]>='A'&&str[i]<='Z')str[i]=str[i]+3;}if(str[i]>='a'&&str[i]<='z'){str[i]=str[i]-3;}}return str;}int main(){char str[80];gets(str);strencode(str);printf("%s\n",str);return 0;}T1008#include<stdio.h>int main(){char a[300],b[300]={'\0'};void del(char *,char *);gets(a);del(a,b);puts(b);return 0;}void del(char *s,char *t){ int i=0;while(*s!='\0'){if(i=1 && *s%2!=0) *t=*s,t++,i=0;s++;}}#include<stdio.h>#include<string.h>char* fun(char *str,char *string){int count=0;for(int i=1;i<strlen(str);i=i+2){if(str[i]%2==1){string[count]=str[i];count++;}}string[count]='\0';return string;}int main(){char str[80],string[80];gets(str);fun(str,string);printf("%s\n",string);return 0;}T1009#include<stdio.h>int main(){char *search(char *p,char ch),a[300],ch,*p;gets(a);ch=getchar();p=search(a,ch);for(;*p==ch && *p!='\0';p++)printf("%c",*p);printf("\n");return 0;char *search(char *p,char ch){int i,max=0;char *pmax;while(*p!='\0'){i=0;while(*p==ch){i++;p++;}if(i>max){max=i;pmax=p-i;}p++;}return pmax;}#include<stdio.h>#include<string.h>char* search(char *cpsourse,char ch) {int count=0,result=0;for(int i=1;cpsourse[i]!='\0';i++){if(cpsourse[i]==ch){count++;}else{if(count>result){result=count;}count=0;}}for(i=0;i<result;i++){printf("%c",ch);}printf("\n");return cpsourse;}int main(){char str[80],string[80],ch;gets(str);scanf("%c",&ch);search(str,ch);return 0;}T1010#include<stdio.h>#include<string.h>int main(){char str[300],fstr[200],rstr[200];void replace(char *str,char *fstr,char *rstr);gets(str);gets(fstr);gets(rstr);replace(str,fstr,rstr);puts(str);return 0;}void replace(char *str,char *fstr,char *rstr){char p[300];int a,b,i;a=strlen(fstr),b=strlen(rstr);while(*str!='\0'){for(i=0;i<a && (str+i)!='\0';i++)if(*(str+i)!=*(fstr+i))break;if(i==a){strcpy(p,str+a);strcpy(str+b,p);strncpy(str,rstr,b);str=str+b;}else str++;}}#include<stdio.h>#include<string.h>char* replace(char *str,char *fstr,char *rstr){int flength,rlength,length;flength=strlen(fstr);rlength=strlen(rstr);length=strlen(str);int i=0;while(str[i]!='\0'){for(int j=0;j<flength;j++)if(str[i+j]!=fstr[j]) break;if(j==flength) //替换{if(flength>rlength){for(int k=0;k<rlength;k++){str[i]=rstr[k];i++;}for(int m=i;str[m]!='\0';m++){str[m]=str[m+(flength-rlength)];}}else if(flength<rlength){for(int m=length+rlength-flength;m>=i+flength;m--){str[m]=str[m-(rlength-flength)];}for(int k=0;k<rlength;k++){str[i]=rstr[k];i++;}length=strlen(str);}else{for(int k=0;k<rlength;k++){str[i]=rstr[k];i++;}}}else i++;}printf("%s\n",str);printf("\n");return str;}int main(){char str[80],fstr[1000],rstr[80],string[80];gets(str);gets(fstr);gets(rstr);replace(str,fstr,rstr);return 0;}SXH01#include<stdio.h>int main(){struct zhigong{char name[9];char id[19];int n;double b;}first;scanf("%s%s%d%lf",,first.id,&first.n,&first.b);printf("姓名=%s 身份证号=%s 工龄=%d 工资=%.2lf\n",,first.id,first.n,first.b); return 0;}SXH05#include<stdio.h>#include<string.h>int main(){struct stu{char no[4];char name[9];int english;int math;}student[5],temp;int i,j;for(i=0;i<5;i++)scanf("%s%s%d%d",student[i].no,student[i].name,&student[i].english,&student[i].math); for(i=0;i<5;i++)for(j=i;j<5;j++){if(strcmp(student[i].name,student[j].name)>0)temp=student[i],student[i]=student[j],student[j]=temp;if(strcmp(student[i].name,student[j].name)==0 && student[i].english>student[j].english)temp=student[i],student[i]=student[j],student[j]=temp;if(strcmp(student[i].name,student[j].name)==0 && student[i].english==student[j].english && student[i].math>student[j].math)temp=student[i],student[i]=student[j],student[j]=temp;}for(i=0;i<5;i++)printf("%s %s %d %d\n",student[i].no,student[i].name,student[i].english,student[i].math);return 0;}。