江苏省计算机等级考试上机材料(C语言) 下载本文

insert_date(y,m,d,str,n);//insert_date(y,m,d,str); 编程:

#include

void fun(int array[],int n) {

int i,j,t;

for(i=0;i

for(j=i+1;j

void main() {

int a[5]={0},m,n=0,i=0,min=0; FILE *fp;

fp=fopen(\ if(fp==0)

{printf(\ clrscr();

scanf(\ if(m/10000!=0) n=5;

else if(m/1000!=0) n=4;

else if(m/100!=0) n=3;

else if(m/10!=0) n=2; else n=1;

fprintf(fp,\ printf(\ i=n-1;

while(m!=0) {

a[i--]=m; m/=10; }

for(i=0;i

{printf(\ printf(\ fun(a,n); i=n-1;

while(i>=0) {

min=min*10+a[i];

}

i--; }

printf(\fprintf(fp,\fclose(fp);

模拟测试题六:

改错:

switch(type)//switch()

xx=xx*16+y[i]-'a'+10;//xx=xx*16+y[i]+'a'-10; *x=sign*xx;//x=sign*xx;

convert(str,t,&number);//number=convert(str,t); 编程:

#include #include #define N 8

typedef struct slist {

double score; struct slist *next; }STREC;

STREC *creatlist(double s[]) {

STREC *head,*p,*q; int i=0;

head=p=(STREC *)malloc(sizeof(STREC)); p->next=0; while(i

q=(STREC *)malloc(sizeof(STREC)); q->score=s[i];p->next=q;p=q;i++; }

p->next=0; return head; }

double fun(STREC *h) {

STREC *p;

double aver=0.0; p=h->next; while(p) {

aver+=p->score/N; p=p->next; }

return aver;

}

void main() {

double s[N]={85,76,69,85,91,72,64,87},aver; STREC *head; int i=0; FILE *fp;

head=creatlist(s); aver=fun(head);

fp=fopen(\ if(fp==0) {

printf(\ exit(-1); }

while(i

printf(\ fprintf(fp,\ }

printf(\

fprintf(fp,\ fclose(fp); }

模拟测试题七:

改错: /* p=p1; p1=p2; p2=p;*/ p=*p1; *p1=*p2; *p2=p;

for(k=j+1;k

if(i%2==0?a[i][j]>a[i][k]:a[i][j]a[i][k]) sort(a); // sort(a[N][N]); 编程:

#include #include void fun(char *s,int m) {

int i=0,n=strlen(s); char t[100]=\ while(i

t[i]=*(s+i);i++; }

for(i=m;i

s[i-m]=s[i]; }

for(i=n-m;i

s[i]=t[i-n+m]; } }

void main() {

char *s=\ int m; FILE *fp;

fp=fopen(\ if(fp==0)

{printf(\ printf(\

gets(s);/*puts(s); */ printf(\

scanf(\ fun(s,m); puts(s);

fprintf(fp,\ fclose(fp); }

模拟测试题八:

改错:

#define N 10 //#define 10 N

char c,color[3]={'B','W','R'}; //char c,color[3]={B,W,R}; if(flag[j]!=color[k]) //if(flag[j]==color[k])

HolandFlag(flag,n); //HolandFlag(flag[N],n); 编程:

#include #include

void sort(int x[][4],int n,int col) {

int p,q,j,t,max,indx; for(p=0;p

indx=p;max=x[p][col]; for(q=p+1;qmax) { max=x[q][col]; indx=q; }