本文目录一览:
- 1、C语言编程:获奖名单统计
- 2、C语言作业
- 3、C++视频教程
C语言编程:获奖名单统计
针对你的要求,编写了以下程序,debug通过:
#include stdio.h
#include string.h
#define NUM 30
#define MAXN 30
int main()
{
char Temp,Name[NUM][MAXN];
double Score[NUM],Sum=0.0;
int i=0,TempPtr,State[NUM];
printf("Please input the IDs and names of students:\n");
for (;iNUM;i++)
{
TempPtr=0;
Temp=getchar();
while (Temp!=' 'Temp!='\n')
{
Name[i][TempPtr++]=Temp;
Temp=getchar();
}
Name[i][TempPtr]='\0';
scanf("%lf",Score[i]);
Sum+=Score[i];
getchar();
}
Sum/=NUM;
for(i=0;iNUM;i++)
{
if (Score[i]Sum*1.05)
{
if (Score[i]Sum*1.1) State[i]=1;
else State[i]=2;
}
else State[i]=0;
}
printf("First Prize:\n");
for(i=0;iNUM;i++)
if (State[i]==1) printf("%s\t%.2lf\n",Name[i],Score[i]);
printf("Second Prize:\n");
for(i=0;iNUM;i++)
if (State[i]==2) printf("%s\t%.2lf\n",Name[i],Score[i]);
return 0;
}
C语言作业
#include stdio.h
#include stdlib.h
double calc( double a )
{
if ( a 500 )
return 0.0;
else if ( a 1000 )
return a*0.05;
else if ( a 2000 )
return a*0.08;
else if ( a 3000 )
return a*0.1;
else
return a*0.15;
}
int main()
{
int n, i;
double *a, *j;
scanf( "%d", n );
a = (double*)malloc( n*sizeof(double) );
j = (double*)malloc( n*sizeof(double) );
for( i=0; in; i++ )
{
scanf( "%lf", a[i] );
j[i] = calc( a[i] );
}
for( i=0; in; i++ )
printf( "%.2f %.2f\n", j[i], a[i]-j[i] );
free( a );
free( j );
}
#include stdio.h
#include stdlib.h
void reverse_array( int arr[], int n )
{
int i = 0;
for( i=0; in/2; i++ )
{
int t = arr[i];
arr[i] = arr[n-1-i];
arr[n-1-i] = t;
}
}
void puts_arr( int *arr, int n )
{
int i;
for( i=0; in; i++ )
{
if ( i%4==0 i!=0 )
printf( " " );
printf( "%d", arr[i] );
}
printf( "\n" );
}
int change( int x, int N )
{
if ( x=0 || !( N1 N10 ) )
{
printf( "Wrong input\n" );
return -1;
}
int sh=x, yu=0, cnt=0;
int arr[1000];
while( sh0 )
{
yu = sh % N;
sh = (int)( sh / N );
arr[cnt] = yu;
cnt++;
}
reverse_array( arr, cnt );
puts_arr( arr, cnt );
return cnt;
}
int main( int argc, char **argv )
{
int i, n, *x, *N;
scanf( "%d", n );
x = (int*)malloc( n*sizeof(int) );
N = (int*)malloc( n*sizeof(int) );
for( i=0; in; i++ )
scanf( "%d %d", x[i], N[i] );
for( i=0; in; i++ )
change( x[i], N[i] );
free( x );
free( N );
}
C++视频教程
王桂林《这可能是你见过“最牛逼”的C++课程》(高清视频)百度网盘
链接:
提取码: rwyi 复制这段内容后打开百度网盘手机App,操作更方便哦
若资源有问题欢迎追问~