[ create a new paste ] login | about

Link: http://codepad.org/FQKaZ6IJ    [ raw code | output | fork ]

C, pasted on May 26:
#include"stdio.h"
#include"conio.h"
#define Fuck 100
void Nhapmang(int a[],int &n)
{ printf("Nhap n:");
scanf("%d",&n);
for(int i=0;i<n;i++){
printf("Phan tu thu a[%d]:\t",i+1);
scanf("%d",&a[i]);
}

}
void Xuatmang(int a[],int n)
{
printf("Noi dung cua mang la:\n");
for(int i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
}
void Tongmang(int a[],int n)
{
int S=0;
	for(int j=35;j>=5;j--)
    for(int i=0;i<n;i++)
	if(a[i]<=a[j]&&a[i]>=a[j-30])
	{
     S+=a[i];
    }
	
}
printf("\nTong cua mang la:%d",S);
}
float TBC(int a[],int n)
{
int TB=0,k=0;
for(int j=10;j<=40;j++){
	for(int i=0;i<n;i++){
		if(a[j]<=a[i]&&a[i]<=a[j+30])
		{
		TB+=a[i];
		k++;}
		break;}}
	printf("%d",TB);
return TB/k;

}
int Min(int a[],int n)
{int min=a[0];
for(int i=1;i<n;i++){
if(min>a[i])
 min=a[i];
}
	return min;
}
int Max(int a[],int n)
{int max=a[0];
for(int i=1;i<n;i++){
 if(max<a[i])
 max=a[i];

}
	 return max;
}
void Sapxep(int a[],int n)
{
int TG;
printf("\nHam sau khi sap xep theo chieu giam dan la:\n");
for(int i=0;i<n-1;i++)
	for(int j=i+1;j<n;j++)
	if(a[i]<a[j]){
	TG=a[i];
	a[i]=a[j];
    a[j]=TG;	
	}
	Xuatmang(a,n);
}
main(){
	int a[Fuck],n;
	float S;
	Nhapmang(a,n);
	Xuatmang(a,n);
	Tongmang(a,n);
S=TBC(a,n);
printf("\nTrung binh cong cua mang trong khoang [10-40]:\t%.3f",S);
	printf("\nMin=%d",Min(a,n));
	printf("\nMax=%d",Max(a,n));
Sapxep(a,n);
	getch();
	return 0;
}


Output:
Line 17: error: conio.h: No such file or directory
Line 4: error: expected ';', ',' or ')' before '&' token
In function 'Xuatmang':
Line 16: error: 'for' loop initial declaration used outside C99 mode
In function 'Tongmang':
Line 24: error: 'for' loop initial declaration used outside C99 mode
Line 25: error: 'for' loop initial declaration used outside C99 mode
t.c: At top level:
Line 32: error: expected declaration specifiers or '...' before string constant
Line 32: error: expected declaration specifiers or '...' before 'S'
Line 32: warning: data definition has no type or storage class
Line 32: error: conflicting types for 'printf'
t.c:33: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
Line 33: error: expected identifier or '(' before '}' token
In function 'TBC':
Line 37: error: 'for' loop initial declaration used outside C99 mode
Line 38: error: 'for' loop initial declaration used outside C99 mode
In function 'Min':
Line 50: error: 'for' loop initial declaration used outside C99 mode
In function 'Max':
Line 58: error: 'for' loop initial declaration used outside C99 mode
In function 'Sapxep':
Line 69: error: 'for' loop initial declaration used outside C99 mode
Line 70: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: