[ create a new paste ] login | about

Link: http://codepad.org/1uZClglr    [ raw code | output | fork | 6 comments ]

C, pasted on Sep 6:
#include<stdio.h>
#include<conio.h>
int main()
{
/*
a  b  c
5  4  7
Giống Interchange sort
a so sánh với b và c
b so sánh với c
*/
	int a, b, c, temp;
	printf("\nNhap a: ");
	scanf("%d", &a);

	printf("\nNhap b: ");
	scanf("%d", &b);

	printf("\nNhap c: ");
	scanf("%d", &c);
	
	if(a > b) 
	{
		temp = a; a = b; b = temp;
	}
	if(a > c)
	{
		temp = a; a = c; c = temp;
	}
	if(b > c)
	{
		temp = b; b = c; c = temp;
	}

	printf("\nTang dan: %d %d %d ",a, b, c);


	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by 01206167662 on Aug 28
#include<stdio.h>
int main()
{
float a,b,c,max;
printf("Nhap vao a = ");scanf("%f",&a);
printf("Nhap vao b = ");scanf("%f",&b);
printf("Nhap vao c = ");scanf("%f",&c);
a>b&&b>c?printf("Thu tu tang dan la: %.2f %.2f %.2f",c,b,a):
a>c&&c>b?printf("Thu tu tang dan la: %.2f %.2f %.2f",b,c,a):
b>c&&c>a?printf("Thu tu tang dan la: %.2f %.2f %.2f",a,c,b):
b>a&&a>c?printf("Thu tu tang dan la: %.2f %.2f %.2f",c,a,b):
c>b&&b>a?printf("Thu tu tang dan la: %.2f %.2f %.2f",a,b,c):
printf("Thu tu tang dan la: %.2f %.2f %.2f",b,a,c);
}
reply
posted by 01206167662 on Aug 28

reply
posted by 19130168@student.hcmus.edu.vn on Oct 16
okay nhưng ai giải thích cho mình hiểu làm sao lại nghĩ ra được cách này ạ?
reply
posted by yonnon on Jul 12
.. bài này hay ghê á :v
reply
posted by yonnon on Jul 12
#include<bits/stdc++.h>

using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
int temp=0;
if(a < b){
temp=a;
a=b;
b=temp;
}
if(b < c){
temp=c;
c=b;
b=temp;
}
if(c < a){
temp=a;
a=c;
c=temp;
}
cout<<" "<<a<<" "<<b<<" "<<c<<" "<<
endl;
return 0;
}
reply
posted by luongphongnhan on Oct 22
#include<iostream>
using namespace std;
int main() {
int a, b, c, temp;
cout << "Moi nhap 3 so:" << endl;
cin >> a >> b >> c;
temp = a;
if (temp > b) {
if (b > c)
{
cout << c << b << a << endl;
}
else
{
cout << b << c << a << endl;
}
}
else {
if (a>=c)
{
cout << c << a << b <<endl;
}
else if(b>=c) {
cout << a << c << b << endl;
}
else
{
cout << a << b << c <<endl;
}
}
system("pause");
return 0;
}
reply