c:
我們提供的服務有:網站設計、成都做網站、微信公眾號開發(fā)、網站優(yōu)化、網站認證、密云ssl等。為千余家企事業(yè)單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的密云網站制作公司
#include?stdio.h
#include?stdlib.h
#include?string.h
int?main(void){
char?(*p)[40];
char?ipv6[40],delims[]?=?":",*result?=?NULL;
int?n,flag=0,len,j;
scanf("%d",n);
p=malloc(sizeof(char?[40])*n);
for(int?i=0;in;i++){
scanf("%s",ipv6);
flag=0;
len=0;
result?=?strtok(ipv6,delims);
while(?result?!=?NULL)?{
if(strcmp(result,"0000")==0){
if(!flag){
flag=1;
strcat(p[i],":");
len++;
}
if(flag==2){
strcat(p[i],"0:");
len+=2;
}
}else{
int?f=0;
for(j=0;jstrlen(result);j++){
if(result[j]=='0'??!f)
continue;
p[i][len++]=result[j];
f=1;
}
strcat(p[i],":");
len++;
if(flag==1)?flag=2;
}
result=?strtok(?NULL,delims);
}
if(flag!=1)
p[i][len-1]='\0';
}
for(int?i=0;in;i++){
printf("%s\n",p[i]);
}
return?0;
}
#include stdio.h
int func(int a[],int n)
{
int i,cnt;
for(cnt=0,i=0;in;++i)
? if(a[i])
? ? ? cnt++;
return cnt;
}
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
printf("%d\n",func(a,10));
return 0;
}
#include?stdio.h
#include?stdlib.h
#include?string.h
int?Input(long?number[],?int?score[][3])?{
int?i=0;
printf("Input?Score:?Number?Grad1?Grad2?Grad3\n");
while?(i30)?{
scanf("%ld?%d?%d?%d",?number[i],?score[i][0],?score[i][1],?score[i][2]);
if?(number[i]0)?break;
i++;
}
return?i;
}
void?Total1(int?score[][3],?float?sum[],?float?aver[],?int?n)?{
int?i;
for?(i=0;in;i++)?{
sum[i]?=?score[i][0]?+?score[i][1]?+?score[i][2];
aver[i]?=?sum[i]/3;
}
}
void?Total2(int?score[][3],?float?sum[],?float?aver[],?int?n)?{
int?i;
sum[0]?=?sum[1]?=?sum[2]?=?0.0f;
for?(i=0;in;i++)?{
sum[0]?+=?score[i][0];
sum[1]?+=?score[i][1];
sum[2]?+=?score[i][2];
}
for?(i=0;i3;i++)
aver[i]?=?sum[i]/3;
}
void?Total3(long?num[],int?score[][3],float?sum[],float?aver[],int?n)?{
int?i,?j;
long?_n;
int?_s;
float?_sum,?_ave;
Total1(score,?sum,?aver,?n);
for?(i=0;in-1;i++)?{
for?(j=n;ji;j--)?{
if?(sum[i]sum[j])?{
//swap?(i,?j)
_n?=?num[i];?num[i]?=?num[j];?num[j]?=?_n;
_s?=?score[i][0];score[i][0]?=?score[j][0];?score[j][0]?=?_s;
_s?=?score[i][1];score[i][1]?=?score[j][1];?score[j][1]?=?_s;
_s?=?score[i][2];score[i][2]?=?score[j][2];?score[j][2]?=?_s;
_sum?=?sum[i];?sum[i]?=?sum[j];?sum[j]?=?_sum;
_ave?=?aver[i];?aver[i]?=?aver[j];?aver[j]?=?_ave;
}
}
}
}
void?Print(long?num[],int?score[][3],float?sum1[],float?aver1[],float?sum2[],float?aver2[],int?n)?{
int?i;
printf("Pos\tNumber\tGrad1\tGrad2\tGrad3\tSum1\tAver1\n");
for?(i=0;in;i++)?{
printf("%d\t%ld\t%d\t%d\t%d\t%.1f\t%.1f\n",?(i+1),?num[i],?score[i][0],?score[i][1],?score[i][2],?sum1[i],?aver1[i]);
}
printf("No\tSum2\tAver2\n");
for?(i=0;i3;i++)?{
printf("%d\t%.1f\t%.1f\n",?(i+1),?sum2[i],?aver2[i]);
}
}
int?main()?{
long?number[30];
int?score[30][3];
float?sum1[30],?aver1[30];
float?sum2[30],?aver2[30];
float?sum3[3],?aver3[3];
int?n;
n?=?Input(number,?score);
Total1(score,?sum1,?aver1,?n);
Total2(score,?sum3,?aver3,?n);
Print(number,?score,?sum1,?aver1,?sum3,?aver3,?n);
Total3(number,?score,?sum2,?aver2,?n);
Print(number,?score,?sum2,?aver2,?sum3,?aver3,?n);
return?0;
}