1设计题: 当前不是空格且下一个是空格,或者下一个字符到末尾了
6要保留两位小数:先乘以1000再加5 再除10 并且变成int 再除以100并把它变成int类型的
42 删除一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。
例如,若一维数组中的数据是:2223445666677899 10 10 10删除后,数组中的内容应该是: 2345678910
for(i=1;i<n;i++)
if(a[j-1]!=a[i]) /*若该数与前一个数不相同,则要保留*/
a[j++]=a[i];
return j;
62
63
void fun (int *a, int *n)
{
int i,j=0;
for(i=1;i<=1000;i++) /*求1到1000之内能被7或11整除、但不能同时被7和11整除的所有整数,并放入数组a中*/
if((i%7==0||i%11==0)&&i%77!=0)
a[j++]=i;
*n=j;
}
76
unsigned fun(unsigned w)
{
unsigned n=w;
int i;
int len=0;
while(n>10)
{
n=n/10;
len++;
}
w=w%(int)pow(10,len);
return w;
}
48
int fun( int t)
{ int j=0;int i;
int a[1000];
a[0]=0;a[1]=1;
for(i=2;i<1000;i++)
{
a[i]=a[i-1]+a[i-2];
if(a[i]>t)
return a[i];
}
}
int fun( int t)
{
int f0 = 0, f1 = 1, f ;
do {
f = f0 + f1 ;
f0 = f1 ;
f1 = f ;
} while(f < t) ;
return f ;
}
25
void fun(int *a, int *b)
{
int i,j;
for(j=0;j<M;j++)
b[j]=0; /*数组b初始化为0*/
for(i=0;i<N;i++)
if(a[i]>=100)
b[10]++; /*如果年龄大于等于100,b[10]自增1*/
else
b[a[i]/10]++; /*如果年龄小于100,则将其分别统计到b[a[i]/10]中*/
}
36
39
47
long fun ( char *p)
{
long n=0;
int flag=1;
if(*p=='-') /*负o数ºy时º¡À置?flag为a-ê-1*/
{p++;flag= -1;}
else if(*p=='+') /*正y数ºy时º¡À置?flag为a1*/
p++;
while(*p!='\0')
{n=n*10+*p-'0'; /*将?字Á?符¤?串ä?转Áa成¨¦相¨¤应®|的Ì?整?数ºy*/
p++;
}
return n*flag;
}
67
double fun( STREC *h )
{ double ave=0.0;
STREC *p=h->next;
while (p!=NULL)
{
ave+=p->s/N;
p=p->next;
}
return ave;
}
76
int n=1,j,s=1;
unsigned t;
t=w;
/*首先确定w的位数,用变量n保存*/
while(t>=10)
{
/*每次循环使s的位数减1,同时n加1*/
t=t/10;
n++;
}
/*求10的n-1次方*/
for(j=1;j<n;j++)
s=s*10;
/*用w对10的n-1次方求余即可得到所求*/
return w%s
unsigned fun(unsigned w)
{
unsigned a=w,n=0;
for(;a>0;a=a/10)
n++;
n--;
w=w%(unsigned)pow(10,n);
return w;
}
倒序
77
void fun(char*s)
{
char i;char t;int k=strlen(s)-1;
for(i=0;i<strlen(s)/2;i++)
{
t=s[i];
s[i]=s[k-i];
s[k-i]=t;
}
}
char ch;
int i,m,n;
i=0;
m=n=strlen(s)-1;
while(i<(n+1)/2)
{
/*使用中间变量叫唤*/
ch=s[i];
s[i]=s[m];
s[m]=ch;
i++; m--;
}
冒泡
int i;int j;char temp;
for(i=1;i<6;i++)
{
for(j=1;j<5;j++)
if(s[i]>s[j])
{
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
91
118
void fun (int *dp,int n,int upordown)
{
int i, temp, index = 0;
if (n==0)return;
for (i = 1; i < n; i++)
{
if (upordown == 0 && dp[i] < dp[index] || upordown == 1 &&dp[i] > dp[index])
{
index = i;
}
}
if (index != 0)
{
temp = dp[index];
dp[index] = dp[0];
dp[0] = temp;
}
}
117
int fun(int xxx[])
{ int i;int j=0;
int a,b,c;
for(i=123;i<=432;i++){
a=i/100;
b=i%100/10;
c=i%10;
if(a>=1&&a<=4&&b>=1&&b<=4&&c>=1&&c<=4&&a!=b&&a!=c&&b!=c){
xxx[j++]=i;
}
}
return j;
}
116
新的几套
#include<stdio.h>
#include<math.h>
#pragma warning(disable:4996)
int prime(int n)
{
int k,flag=1;
for (k=2; k<=(int)sqrt((double)n); k++)
if (n%k == 0)
flag=0;
return flag;
}
int fun(int m, int a[])
{
int k, s, count, i=0;
for(k=6; k<=m; k+=2)
{
count = 0;
/* 请在此处填写代码 */
for( s=2;s<=k/2;s++)
{
if(prime(s)==1&& prime(k-s)==1)
{
count++;
}
}
if (count == 10) {
printf("%d\n", k);
a[i++] = k;
}
}
return i;
}
main( )
{
int count, a[100];
void NONO(int count, int a[]);
count = fun(999, a);
NONO(count, a);
}
void NONO(int count, int a[])
{
FILE *fp;
int i;
fp = fopen("out.dat","w") ;
for(i=0; i<count; i++)
fprintf(fp, "%d\n", a[i]);
fclose(fp);
}
长得很像的几道题
void fun( char *a )
{
int i=0,n=0;
char *p;
p=a;
while (*p=='*')
{
n++;p++;
}
while(*p)
{
a[i]=*p;i++;p++;
}
while(n!=0)
{
a[i]='*';i++;n--;
}
a[i]='\0';
}
void fun( char *a, char *h,char *p )
{
int i=0;
char *q=a;
while(q<h)
{
a[i]=*q;
q++;
i++;
}
while(q<p)
{
if(*q!='*')
{a[i]=*q;
i++;
}
q++;
}
while(*q)
{
a[i]=*q;
i++;
q++;
}
a[i]='\0';
}
void fun( char *a, int n )
{
int i=0;
int k=0;
char *p,*t;
p=t=a;
while(*t=='*'){
k++;t++;
}
if(k>n)
{
while(*p){
a[i]=*(p+k-n);
i++;
p++;
}
a[i]='\0';
}
}
void fun( char *a,int n )
{
//第一步相同指针*t移到最后 第二步通过向前遍历直到遇到最后一个字母计算出k的值 若k<n 另设一个指针和a一样*p 将*p遍历到t(指向最后一个字母)+n+1
记得\0
int i=0,k=0;
char *p, *t; //根据t判断
p=t=a;
while(*t)
t++;
t--; //t指向最后
while(*t=='*') //判断有多少个*
{k++;t--;} //t指向最后一个字母
if(k>n)
{
while(*p&&p<t+n+1) //p小于最后一个*
{
a[i]=*p;
i++;p++;
}
a[i]='\0';
}
}
#include <stdio.h>
void fun( char *a )
{
int i=0;
char *p=a;
while(*p&&*p=='*')
{
a[i]=*p;
i++;
p++;
}
while(*p)
{
if(*p!='*')
{a[i]=*p;i++;}
p++;
}
a[i]='\0';
}
int i,j;int k=0;
for(i=0;a[i]=='*';i++);
j=i;
for(;a[i]!=0;i++)
if(a[i]!='*')
a[j++]=a[i];
a[j]=0;
void fun( char *a )
{
int i=0;
while (a[i]!=0)
i++;
i--;
for(;a[i]=='*';i--);
a[i+1]='\0';
}
void fun( char *a, int n,int h,int e )
{
int i,j=0;
for(i=h;i<n-e;i++)
a[j++]=a[i];
a[j]='\0';
}
void fun( char *a )
{
char *p=a;
while(*p=='*') p++;
for(;*p!='\0';p++,a++)
*a=*p;
*a='\0';
}
#include <stdio.h>
void fun( char *a, char *p )
{
char *t=a;
for(;t<=p;t++)
if(*t!='*')
*(a++)=*t;
for(;*t!='\0';t++)
*(a++)=*t;
*a='\0';
}
void main()
{ char s[81],*t;
void NONO ( );
printf("Enter a string:\n");gets(s);
t=s;
while(*t)t++;
t--;
while(*t=='*')t--;
fun( s , t );
printf("The string after deleted:\n");puts(s);
NONO();
}
void NONO()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
FILE *in, *out ;
int i ; char s[81],*t ;
in = fopen("in.dat","r") ;
out = fopen("out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(in, "%s", s) ;
t=s;
while(*t)t++;
t--;
while(*t=='*')t--;
fun(s,t) ;
fprintf(out, "%s\n", s) ;
}
fclose(in) ;
fclose(out) ;
}
填空修改题
#include <stdio.h>
#include <conio.h>
/*************found**************/
void fun(int m,int k)
{ int aa[20], i;
for(i=0;m;i++)
{
/*************found**************/
aa[i]=m%k;
m/=k;
}
for(;i;i--)
/*************found**************/
printf("%d",aa[i-1]);
}
void main()
{
int b,n;
printf("\nPlease enter a number and a base:\n");
scanf("%d%d",&n,&b);
fun(n,b);
printf("\n ");
}
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
double fun(int m)
{
double t=1.0;
int i;
for(i=2;i<=m;i++)
/*************found**************/
t-=1.0/i;
/*************found**************/
return t ;
}
void main()
{int m;
system("CLS");
printf("\nPlease enter 1 integer numbers:\n");
scanf("%d",&m);
printf("\n\nThe result is %1f\n",
fun(m));
}
#include <stdio.h>
double f1(double x)
{ return x*x; }
double f2(double x, double y)
{ return x*y; }
double fun(double a, double b)
{
/**********found**********/
double (*f)();
double r1, r2;
/**********found**********/
f = f1 ;
r1 = f(a);
/**********found**********/
f = f2 ;
r2 = (*f)(a, b);
return r1 + r2;
}
void main()
{ double x1=5, x2=3, r;
r = fun(x1, x2);
printf("\nx1=%f, x2=%f, x1*x1+x1*x2=%f\n",x1, x2, r);
}
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct aa
{ int data;
struct aa *next;
} NODE;
int fun (NODE *h)
{ int sum=0;
NODE *p;
p=h->next;
/*************found**************/
while(p!=NULL)
{ if(p->data%2==0)
sum+=p->data;
/*************found**************/
p=p->next;
}
return sum;
}
NODE *creatlink(int n)
{
NODE *h,*p,*s;
int i;
h=p=(NODE*)malloc(sizeof(NODE));
for(i=1;i<n;i++)
{
s=(NODE*)malloc(sizeof(NODE));
s->data=rand()%16;
s->next=p->next;
p->next=s;
p=p->next;
}
p->next=NULL;
return h;
}
void outlink(NODE *h)
{ NODE *p;
p=h->next;
printf("\n\n The LIST :\n\n HEAD");
while(p)
{ printf("->%d",p->data);
p=p->next;}
printf("\n");
}
void main()
{ NODE *head; int sum;
system("CLS");
head=creatlink(10);
outlink(head);
sum=fun(head);
printf("\nSUM=%d",sum);
}
#include <stdio.h>
#include <stdlib.h>
#define N 6
typedef struct node {
int data;
struct node *next;
} NODE;
void fun(NODE *h)
{ NODE *p, *q; int t;
/**********found**********/
p = h->next ;
while (p) {
/**********found**********/
q = p->next;
while (q) {
/**********found**********/
if (p->data > q->data)
{ t = p->data; p->data = q->data; q->data = t; }
q = q->next;
}
p = p->next;
}
}
NODE *creatlist(int a[])
{ NODE *h,*p,*q; int i;
h = (NODE *)malloc(sizeof(NODE));
h->next = NULL;
for(i=0; i<N; i++)
{ q=(NODE *)malloc(sizeof(NODE));
q->data=a[i];
q->next = NULL;
if (h->next == NULL) h->next = p = q;
else { p->next = q; p = q; }
}
return h;
}
void outlist(NODE *h)
{ NODE *p;
p = h->next;
if (p==NULL) printf("The list is NULL!\n");
else
{ printf("\nHead ");
do
{ printf("->%d", p->data); p=p->next; }
while(p!=NULL);
printf("->End\n");
}
}
void main()
{ NODE *head;
int a[N]= {0, 10, 4, 2, 8, 6 };
head=creatlist(a);
printf("\nThe original list:\n");
outlist(head);
fun(head);
printf("\nThe list after sorting :\n");
outlist(head);
}
#include <stdio.h>
#define M 3
#define N 5
void fun(int (*a)[N],int k)
{ int i,j,p,temp;
/**********found**********/
for(p=1; p<= k; p++)
for(i=0; i<M; i++)
{ temp=a[i][0];
/**********found**********/
for(j=0; j<N-1; j++) a[i][j]=a[i][j+1];
/**********found**********/
a[i][N-1]= temp;
}
}
void main( )
{ int x[M][N]={ {1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5} },i,j;
printf("The array before moving:\n\n");
for(i=0; i<M; i++)
{ for(j=0; j<N; j++) printf("%3d",x[i][j]);
printf("\n");
}
fun(x,2);
printf("The array after moving:\n\n");
for(i=0; i<M; i++)
{ for(j=0; j<N; j++) printf("%3d",x[i][j]);
printf("\n");
}
}
#include <stdio.h>
#define M 3
#define N 4
void fun(int (*a)[N])
{ int i=0,j,find=0,rmax,c,k;
while( (i<M) && (!find))
{ rmax=a[i][0]; c=0;
for(j=1; j<N; j++)
if(rmax<a[i][j]) {
/**********found**********/
rmax=a[i][j]; c= j; }
find=1; k=0;
while(k<M && find) {
/**********found**********/
if (k!=i && a[k][c]<=rmax) find= 0 ;
k++;
}
if(find) printf("find: a[%d][%d]=%d\n",i,c,a[i][c]);
/**********found**********/
i++;
}
if(!find) printf("not found!\n");
}
void main()
{ int x[M][N],i,j;
printf("Enter number for array:\n");
for(i=0; i<M; i++)
for(j=0; j<N; j++) scanf("%d",&x[i][j]);
printf("The array:\n");
for(i=0; i<M; i++)
{ for(j=0; j<N; j++) printf("%3d",x[i][j]);
printf("\n\n");
}
fun(x);
}
#include <stdio.h>
#include <string.h>
#define N 80
void fun(char *s, int n, char *t)
{ int len,i,j=0;
len=strlen(s);
/**********found**********/
if(n>=len) strcpy(t,s);
else {
/**********found**********/
for(i=len-n; i<=len-1; i++) t[j++]= s[i] ;
/**********found**********/
t[j]= 0;
}
}
void main()
{ char s[N],t[N]; int n;
printf("Enter a string: ");gets(s);
printf( "Enter n:"); scanf("%d",&n);
fun(s,n,t);
printf("The string t : "); puts(t);
}
int fun(char *s)
{ int n=0, flag=0;
while(*s!='\0')
{ if(*s!=' ' && flag==0) {
/**********found**********/
n++ ; flag=1;}
/**********found**********/
if (*s==' ') flag= 0 ;
/**********found**********/
s++;
}
return n;
}
- 字符串长度排序
#include <stdio.h>
#include <string.h>
#define N 5
#define M 8
void fun(char (*ss)[M])
{ char *ps[N],*tp; int i,j,k;
for(i=0; i<N; i++) ps[i]=ss[i];
for(i=0; i<N-1; i++) {
/**********found**********/
k= i ;
for(j=i+1; j<N; j++)
/**********found**********/
if(strlen(ps[k]) < strlen(ps[j]) ) k=j;
/**********found**********/
tp=ps[i]; ps[i]=ps[k]; ps[k]= tp;
}
printf("\nThe string after sorting by length:\n\n");
for(i=0; i<N; i++) puts(ps[i]);
}
void main()
{ char ch[N][M]={"red","green","blue","yellow","black"};
int i;
printf("\nThe original string\n\n");
for(i=0;i<N;i++)puts(ch[i]); printf("\n");
fun(ch);
}
#include <stdio.h>
#define N 5
typedef struct student {
long sno;
char name[10];
float score[3];
} STU;
void fun(char *filename)
{ FILE *fp; int i, j;
STU s[N], t;
/**********found**********/
fp = fopen(filename, "rb");
fread(s, sizeof(STU), N, fp);
fclose(fp);
for (i=0; i<N-1; i++)
for (j=i+1; j<N; j++)
/**********found**********/
if (s[i].sno >s[j].sno)
{ t = s[i]; s[i] = s[j]; s[j] = t; }
fp = fopen(filename, "wb");
/**********found**********/
fwrite(s, sizeof(STU), N, fp);
fclose(fp);
}
void main()
{ STU t[N]={ {10005,"ZhangSan", 95, 80, 88}, {10003,"LiSi", 85, 70, 78},
{10002,"CaoKai", 75, 60, 88}, {10004,"FangFang", 90, 82, 87},
{10001,"MaChao", 91, 92, 77}}, ss[N];
int i,j; FILE *fp;
fp = fopen("student.dat", "wb");
fwrite(t, sizeof(STU), 5, fp);
fclose(fp);
printf("\n\nThe original data :\n\n");
for (j=0; j<N; j++)
{ printf("\nNo: %ld Name: %-8s Scores: ",t[j].sno, t[j].name);
for (i=0; i<3; i++) printf("%6.2f ", t[j].score[i]);
printf("\n");
}
fun("student.dat");
printf("\n\nThe data after sorting :\n\n");
fp = fopen("student.dat", "rb");
fread(ss, sizeof(STU), 5, fp);
fclose(fp);
for (j=0; j<N; j++)
{ printf("\nNo: %ld Name: %-8s Scores: ",ss[j].sno, ss[j].name);
for (i=0; i<3; i++) printf("%6.2f ", ss[j].score[i]);
printf("\n");
}
}
#include <stdio.h>
#define N 100
void fun( int *a , int n )
{ int i, t;
for( i=0; i<n; i++ )
/**********found**********/
a[i]=0;
i=0;
/**********found**********/
t=1;
while( i<n )
{ a[i]= 1;
t++;
/**********found**********/
i=i+t;
}
}
void main()
{ int a[N], i, n=30;
fun( a, n);
for(i=0; i<n; i++)
if( a[i]==1 ) printf("不安全的洞号是 : %d\n",i );
}
void fun(char *s, char c)
{ int i, j, n;
/**********found**********/
for(i=0; s[i]!=0; i++)
if(s[i]==c)
{
/**********found**********/
n=0 ;
while(s[i+1+n]!='\0') n++;
for(j=i+n+1; j>i; j--) s[j+1]=s[j];
/**********found**********/
s[j+1]= c;
i=i+1;
}
}
void fun(char *s, int a, double f)
{
/**********found**********/
__1__ fp;
char str[100], str1[100], str2[100];
int a1; double f1;
fp = fopen("file1.txt", "w");
fprintf(fp, "%s %d %f\n", s, a, f);
/**********found**********/
__2__ ;
fp = fopen("file1.txt", "r");
/**********found**********/
fscanf(__3__,"%s%s%s", str, str1, str2);
fclose(fp);
a1 = atoi(str1);
f1 = atof(str2);
printf("\nThe result :\n\n%s %d %f\n", str, a1, f1);
}
STU *fun(STU a[], int m)
{ STU b[N],*t;
int i, j,k;
/*************found**************/
*t=calloc(m,sizeof(STU));
for(i=0;i<N;i++) b[i]=a[i];
for(k=0;k<m;k++)
{ for (i=j=0;i<N;i++)
if(b[i].s>b[j].s) j=i;
/*************found**************/
t[k].num=b[j].num;
t[k].s=b[j].s;
b[j].s=0;
}
return t;
}
/**********found**********/
void fun(char (*ss) __1__, int k)
{ int i=0 ;
/**********found**********/
while(i< __2__) {
/**********found**********/
ss[i][k]=__3__; i++; }
}
void fun(int (*t)[N])
{ int i, j, x;
/**********found**********/
for(i=0; i<___1___; i++)
{
/**********found**********/
x=t[i][___2___] ;
for(j=N-1; j>=1; j--)
t[i][j]=t[i][j-1];
/**********found**********/
t[i][___3___]=x;
}
}
void fun(int ___1___, int n)
{ int i, j, max, min, px, pn, t;
/**********found**********/
for (i=0; i<n-1; i+=___2___)
{ max = min = a[i];
px = pn = i;
/**********found**********/
for (j=___3___; j<n; j++)
{ if (max < a[j])
{ max = a[j]; px = j; }
if (min > a[j])
{ min = a[j]; pn = j; }
}
if (px != i)
{ t = a[i]; a[i] = max; a[px] = t;
if (pn == i) pn= px;
}
if (pn != i+1)
{ t = a[i+1]; a[i+1] = min; a[pn] = t; }
}
}
int fun(int a[], int n)
{ int i,j;
j = 0;
for (i=0; i<n; i++)
/**********found**********/
if (___1___== 0) {
/**********found**********/
___2___ = a[i]; j++;
}
/**********found**********/
return ___3___;
}
void fun( char *p )
{ char max,*q; int i=0;
max=p[i];
while( p[i]!=0 )
{ if( max<p[i] )
{ max=p[i];
/**********found**********/
q=p+i
}
i++;
}
/**********found**********/
while(q<p )
{ *q=*(q-1);
q--;
}
p[0]=max;
}
typedef struct
{ char num[10];
int year,month,day ;
}STU;
/**********found**********/
__1__ fun(STU *std, char *num)
{ int i; STU a={"",9999,99,99};
for (i=0; i<N; i++)
/**********found**********/
if( strcmp(__2__,num)==0 )
/**********found**********/
return (__3__);
return a;
}
void fun(char *s)
{ int i, j=0, k=0; char t1[80], t2[80];
for(i=0; s[i]!='\0'; i++)
if(s[i]>='0' && s[i]<='9')
{
/**********found**********/
t2[j]=s[i]; j++;
}
else t1[k++]=s[i];
t2[j]=0; t1[k]=0;
/**********found**********/
for(i=0; i<k; i++) ___2___;
/**********found**********/
for(i=0; i<___3___; i++) s[k+i]=t2[i];
}
void fun( SLIST *h, int x)
{ SLIST *p, *q, *s;
s=(SLIST *)malloc(sizeof(SLIST));
/**********found**********/
s->data=___1___;
q=h;
p=h->next;
while(p!=NULL && x>p->data) {
/**********found**********/
q=___2___;
p=p->next;
}
s->next=p;
/**********found**********/
q->next=___3___;
}
int fun(int n)
{ int a[10000], i,j, count=0;
for (i=2; i<=n; i++) a[i] = i;
i = 2;
while (i<n) {
/**********found**********/
for (j=a[i]*2; j<=n; j+=___1___)
a[j] = 0;
i++;
/**********found**********/
while (___2___==0)
i++;
}
printf("\nThe prime number between 2 to %d\n", n);
for (i=2; i<=n; i++)
/**********found**********/
if (a[i]!=___3___)
{ count++; printf( count%15?"%5d":"\n%5d",a[i]); }
return count;
}
#define OK(i, t, n) ((___1___%t==0) && (i/t<n))
int fun(int t1, int t2, int t3, int t4, int n)
{ int count, t , maxt=t1;
if (maxt < t2) maxt = t2;
if (maxt < t3) maxt = t3;
if (maxt < t4) maxt = t4;
count=1; /* 给count赋初值 */
/**********found**********/
for(t=1; t< maxt*(n-1); ___2___)
{
if(OK(t, t1, n) || OK(t, t2, n)|| OK(t, t3, n) || OK(t, t4, n) )
count++;
}
/**********found**********/
return ___3___;
}
void fun(char (*ss)[N])
{ int i, j, k=0, n, m, len;
for(i=0; i<M; i++)
{ len=strlen(ss[i]);
if(i==0) n=len;
if(len>n) {
/**********found**********/
n=len; ___1___=i;
}
}
for(i=0; i<M; i++)
if (i!=k)
{ m=n;
len=strlen(ss[i]);
/**********found**********/
for(j=___2___; j>=0; j--)
ss[i][m--]=ss[i][j];
for(j=0; j<n-len; j++)
/**********found**********/
___3___='*';
}
}
void fun(char (*ss)[N])
{ int i, j, n, len=0;
for(i=0; i<M; i++)
{ n=strlen(ss[i]);
if(i==0) len=n;
if(len<n)len=n;
}
for(i=0; i<M; i++) {
/**********found**********/
n=strlen(___1___);
for(j=0; j<len-n; j++)
/**********found**********/
ss[i][___2___]='*';
/**********found**********/
ss[i][n+j+___3___]='\0';
}
}
void fun(char *p)
{
int k=0;
for ( ;*p;p++)
if (k)
{
/*************found**************/
if (*p==' ')
{
k=0;
/*************found**************/
*p=toupper( *(p));
}
}
else
k=1;
}
int fun(char (*ss)[M], int *n)
{ int i, k=0, len=0;
for(i=0; i<M; i++)
{ len=strlen(ss[i]);
/**********found**********/
if(i==0) *n=len;
if(len>*n) {
/**********found**********/
___3___;
k=i;
}
}
return(k);
}
int fun()
{ int i,j,k,sum=0;
printf("\nThe result :\n\n ");
/*************found**************/
for(i=0;i<=3;i++)
{ for (j=1;j<=5;j++)
{k=8-i-j;
/*************found**************/
if(k>=1&&k<=6)
{ sum=sum+1;
printf("red:%4d white:%4dblack:%4d\n ",i,j,k);
}
}
}
return sum;
}
double fun(double x)
{ double f, t; int n;
f = 1.0 + x;
t=___1___;
n = 1;
do {
n++;
t*=(-1.0)*x/___2___;
f += t;
}
while(___3___ >=1e-6);
return f;
}
void fun(long n)
{
c1=c2=c3=0;
while(n)
{
switch(n)
{
case 1:
c1++;break;
case 2:
c2++;break;
case 3:
c3++;
}
n/=10;
}
}
void fun(char *s)
{ int i, n, k; char c;
n=0;
for(i=0; s[i]!='\0'; i++) n++;
/**********found**********/
if(n%2==0) k=n-___1___ ;
else k=n-2;
/**********found**********/
c=___2___ ;
for(i=k-2; i>=1; i=i-2) s[i+2]=s[i];
/**********found**********/
s[1]=___3___ ;
}
void fun( SLIST *p)
{ SLIST *t, *s;
t=p->next; s=p;
while(t->next != NULL)
{ s=t;
/**********found**********/
t=t->___1___;
}
/**********found**********/
printf(" %d ",___2___);
s->next=NULL;
/**********found**********/
free(___3___);
}
int fun(char *source, char *target)
{ FILE *fs,*ft; char ch;
/**********found**********/
if((fs=fopen(source, ___1___))==NULL)
return 0;
if((ft=fopen(target, "w"))==NULL)
return 0;
printf("\nThe data in file :\n");
ch=fgetc(fs);
/**********found**********/
while(!feof(___2___))
{ putchar( ch );
/**********found**********/
fputc(ch,___3___);
ch=fgetc(fs);
}
fclose(fs); fclose(ft);
printf("\n\n");
return 1;
}
void fun(int (*t)[N], int m)
{ int i, j;
/**********found**********/
for(i=0; i<N; ___1___ )
{ for(j=N-1-m; j>=0; j--)
/**********found**********/
t[i][j+___2___ ]=t[i][j];
/**********found**********/
for(j=0; j<___3___; j++)
t[i][j]=0;
}
}
求几个数的公倍数
{ int j,t ,n ,m;
j = 1 ;
t=j%x;
m=j%y ;
n=j%z;
while(t!=0||m!=0||n!=0)
{ j = j+1;
t=j%x;
m=j%y;
n=j%z;
}
/************found************/
return j;
}
double fun(double a, double x0)
{ double x1, y;
x1=(x0+ a/x0)/2.0;
/**********found**********/
if( fabs(x1-x0)>=0.00001 )
y=fun(a,x1);
else y=x1;
return y;
}
注意有个等于号
/************found************/
#define FU(m,n) ((m/n))
float fun(float a,float b,float c)
{ float value;
value=FU(a+b,a-b)+FU(c+b,c-b);
/************found************/
Return(Value);
}
void fun( int *px, int *py)
{
/**********found**********/
int k,a=0,b=0;
scanf( "%d", &k );
/**********found**********/
while (k)
{ if (k>0 ) a++;
if(k<0 ) b++;
/**********found**********/
scanf( "%d", &k );;
}
*px=a; *py=b;
}
判我错了
int fun(LIST *h)
{ LIST *p;
/**********found**********/
int t;
p=h;
/**********found**********/
while( *p )
{
/**********found**********/
t=t+p.data;
p=(*p).next;
}
return t;
}
int fun(int n, int a[], int *k)
{ int m=0, i, t;
t = n;
/**********found**********/
for( i=0; i<n; i++ )
if(n%i==0)
{ a[m]=i; m++; t=t - i; }
/**********found**********/
k=m;
/**********found**********/
if ( t=0 ) return 1;
else return 0;
}
连续正整数序列之和
#include <stdio.h>
void fun( int n )
{ int j, b, c, m, flag=0;
for (b=1; b<=n/2; b++) {
/**********found**********/
m=n;
c = b;
while (m !=0 && m>=c) {
/**********found**********/
m = m - c; c++;
}
/**********found**********/
if ( m==0)
{ printf("%d=", n);
for (j=b; j<c-1; j++) printf( "%d+", j );
printf("%d\n", j);
flag=1;
}
}
if(flag==0)
printf("不能分解\n");
}
void main()
{ int n;
printf("请输入一个整数 : "); scanf("%d", &n);
fun(n);
}
long fun(int n)
{
static struct Ord old={0,1};
int i;
if(n==old.n)
/**********************found***********************/
return (____(1)____);
if(n>old.n)
for(i=old.n+1;i<=n;i++)
old.ordor*=i;
else
for(i=old.n;i>n;i--)
old.ordor/=i;
/**********************found***********************/
old.n=____(2)____;
/**********************found***********************/
return ( ____(3)____);
}
void fun( char *s1, char *s2, char *s3)
{ int i,j;
/**********************found***********************/
for(i = 0, j = 0; (s1[i] != '\0') && (s2[i] != '\0'); i++, j = j + 1)
{ s3[j] = s1[i];
s3[j+1] = s2[i];
}
if (s2[i] != '\0')
{ for(; s2[i] != '\0'; i++, j++)
/**********************found***********************/
s3[i] = s2[j];
}
else if (s1[i] != '\0')
{ for(; s1[i] != '\0'; i++, j++)
s3[j] = s1[i];
}
/**********************found***********************/
s3[j-1] = '\0';
}
有的题目是真的恶心 结果是对的,但是就给我对一个空
void fun( char *s )
{ int i;
/**********************found***********************/
static int n = 1;
if ( n++ %2 )
/**********************found***********************/
for(i=0;i<strlen(s);i++)
printf("%c", islower(s[i]) ? toupper(s[i]) : s[i]);
else
/**********************found***********************/
for (i = strlen(s)-1; i>=0; i--)
printf("%c", s[i]);
}
void func(int xx[], int num)
{
int n1,n2,pos,i,j;
pos=xx[9];
if (num > pos)
/**********found**********/
xx[10] = __(1)___;
else {
for(i=0;i<10;i++)
{
if(xx[i]>num){
n1=xx[i];
xx[i]=num;
for(j=i+1;j<11;j++){
n2=xx[j];
xx[j] = n1;
/**********found**********/
_____(2)____;
}
/**********found**********/
_____(3)_____;
}
}
}
}
int func(int (*p)[4], int m, int n, int *pRow, int *pCol)
{
int i, j, max;
/**********found**********/
max = p[0][0];
*pRow = 0;
*pCol = 0;
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if ( *(*(p+i)+j) > max)
{
max = *(*(p+i) + j);
*pRow = i;
/**********found**********/
*pCol = j;
}
}
}
/**********found**********/
return max;
}
第一空我这样写不给分……
跟上面一题很像的
void fun(char *s1, char *s2, char *s3)
{
int i,j,L2;
L2=strlen(s2);
for(i=0,j=0;(s1[i]!='\0')&&(s2[i]!='\0');i++,j=j+2)
{
s3[j]=s1[i];
/***********found**********/
s3[j+1]=s2[i];
}
/***********found**********/
if(s1[i]=='\0')
for(;s1[i]!='\0';i++,j+=1)
s3[j]=s1[i];
else if (s2[i]!='\0')
for(;s2[i]!='\0';i++,j++)
s3[j]=s2[L2-1-i];
/***********found**********/
s3[i]='0';
}
void fun(char c, int d) {
int i;
char A[26], a[26], *ptr;
/**********found**********/
for (i=0; i<26; i++) {
A[i] = 'A' + i;
a[i] = 'a' + i;
}
/**********found**********/
if ((c >= 'a') && (c<= 'z')) ptr = a;
else ptr = A;
/**********found**********/
for (i=1; i<=d; i++) printf("%c", ptr[(c-ptr[0]+i) % ____(3)____] );
}
注意第二个空没等号
int fun(char* str) {
int k, c0, c1;
c0 = c1 = -1;
for (k=0; k<strlen(str); k++)
if ( (str[k] >= 'A') && (str[k] <= 'Z') )
{ c0 = c1 = k;
break;
}
if (c0 == -1)
return 0;
/**********************found***********************/
for (k=0; k<strlen(str)-1; k++)
{
/**********************found***********************/
if ( (str[k] >= 'A') || (str[k] <= 'Z') )
{
if (str[k] < str[c0])
c0 = k;
if (str[k] > str[c1])
c1 = k;
}
}
/**********************found***********************/
return c1 - c0;
}
void fun(char c, int d) {
int i;
char A[26], a[26], *ptr;
/**********found**********/
for (i=0; i<26; i++) {
A[i] = 'A' + i;
a[i] = 'a' + i;
}
/**********found**********/
if ((c >= 'a') && (c<= 'z')) ptr = a;
else ptr = A;
/**********found**********/
for (i=1; i<=d; i++) printf("%c", ptr[(c-ptr[0]+i) % ____(3)____] );
}
注意第二个空没等号
int fun(char* str) {
int k, c0, c1;
c0 = c1 = -1;
for (k=0; k<strlen(str); k++)
if ( (str[k] >= 'A') && (str[k] <= 'Z') )
{ c0 = c1 = k;
break;
}
if (c0 == -1)
return 0;
/**********************found***********************/
for (k=0; k<strlen(str)-1; k++)
{
/**********************found***********************/
if ( (str[k] >= 'A') || (str[k] <= 'Z') )
{
if (str[k] < str[c0])
c0 = k;
if (str[k] > str[c1])
c1 = k;
}
}
/**********************found***********************/
return c1 - c0;
}