## 第二次作业

2018-04-08 20:22  无敌伟业  阅读(206)  评论(4编辑  收藏  举报
void delnum(char *s)
{
int a = 0,j;
while(s[a]!='\0') {
if(s[a] >= '0' && s[a] <= '9') {
j = a;
while(s[j]!='\0') {
s[j] = s[j+1];
j++;
}
continue;
}
a++;
}
}



int fun(char *str,char *substr)
{
int a,b,k,num=0;
for(a = 0;str[a];a++)
for(b=a,k=0;substr[k]==str[b];k++,b++)

if(substr[k+1]=='\0')

{
num++;
break;
}
return(num);
}



int fun(char *s,int num)
{
int a=0, b=0, k=0, n=0;
char t;
for(n=0;;n++)
{
if(*(s+n)=='\0')break;
}
n--;
for(a=1;a<n-1;a++)
{
for(b=a;b<n;b++)
{
if(*(s+a)<*(s+b))
{
t=*(s+a);
*(s+a)=*(s+b);
*(s+b)=t;
}
}
}
}



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
int n,i;
double max=0,min=100,sum=0,now;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%lf",&now);
if(now>max) max=now;
if(now<min) min=now;
sum=sum+now;
}
printf("average = %.2lf\n",sum/n);
printf("max = %.2lf\n",max);
printf("min = %.2lf",min);

return 0;
}



#include <stdio.h>
struct zhigong
{
char name[10];
float a,b,c;
};
int main()
{
int N,i,j;
float sum;
scanf("%d",&N);
struct zhigong xu;
for(i = 0;i < N;i++)
{
// struct zhigong xu;
scanf("%s",xu.name);
scanf("%f",&xu.a);
scanf("%f",&xu.b);
scanf("%f",&xu.c);
sum = xu.a + xu.b - xu.c;
printf("%s %.2f\n",xu.name,sum);
}

return 0;
}



#include<stdio.h>
struct student
{
char  number[1000];
char name[100];
float a;
}student;
int main()
{
int n,i,j;
float sum=0.00,ave=0.00;
scanf("%d", &n);
struct student s[n];
for (i = 0; i < n; i++)
{
scanf("%s %s %f",&s[i].number,s[i].name,&s[i].a);
sum=sum+s[i].a;
}
ave=sum/n;
printf("%.2f\n",ave);
for (j = 0; j < n;j++)
{
if(s[j].a<ave)
{
printf("%s %s\n", s[j].name, s[j].number);
}
}
return 0;
}



int set_grade( struct student *p, int n )
{
int i = 0,count = 0;
for(i = 0;i < n;i++)
{
if((p[i].score>= 85) && (p[i].score <= 100))
{
}
if((p[i].score >= 70) && (p[i].score <= 84))
{
}
if((p[i].score) >= 60 && (p[i].score <=69))
{
}
if((p[i].score >= 0) && (p[i].score <= 59))
{
}
{
count ++;
}
}
return count;
}


void calc(struct student *p,int n)
{
int i;
float k;
for(i = 0;i < n;i++)
{
p[i].sum = p[i].score[0]+ p[i].score[1] + p[i].score[2];
}
}
void sort(struct student *p,int n)
{
int i,j;
struct student t;
for(i = 0;i < n - 1;i++)
{
for(j = 0;j <n-i-1;j++)
{
if(p[j].sum < p[j+1].sum)
{
t = p[j];
p[j]= p[j+1];
p[j+1] = t;

}
}
}
}