[ create a new paste ] login | about

Link: http://codepad.org/Q5TRCwnZ    [ raw code | output | fork | 4 comments ]

C, pasted on Aug 22:
#include<stdio.h>
#include<conio.h>


int main()
{
	int i, n;
	int max;
	max = 0;
	do
	{
	printf("\nNhap n: ");
	scanf("%d", &n);
	}while(n < 0 && printf("\nLoi: n >= 0 !"));
	if(n == 0)
		max = 0;

	do
	{
		i = n % 10;
	   if(i > max)
	   {
		   max = i;
	   }
	}while(n /= 10);

	printf("\nChu so lon nhat la %d", max);

	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 mouto9k on Nov 15
max=0;
...//if(cs>max)
max=cs;
reply
posted by yonnon on Jul 9
#include<bits/stdc++.h>

struct S
{
int number;
};
using namespace std;
int main(){
int n;
int *p;
cout << "Enter your sentence: ";
cin >> n;
p=&n;
int n2=*p;
int temp1=0;
while(n2!=0){
temp1++;
n2/=10;

}
S *temp= new S[n];
for(int i=0; i<temp1; ++i){
temp[i].number=n%10;
n/=10;
}
S x=temp[0];
for(int i=0; i<temp1; ++i){
if(temp[i].number>x.number){
x=temp[i];
}
}
cout<<"Max number is "<<x.number<<
endl;

return 0;

}
reply
posted by yonnon on Jul 9
t còn thấy t làm dài dòng vl mà =))

reply
posted by cuong.luucb8921 on Aug 21
#include<stdio.h>

int main(){
int n;
int t;
int s;
int max=1;

do
{
printf("Nhap vap n:\n");
scanf("%d",&n);
if(n < 1)
{
printf("n phai lon hon bang 1\n");
}
}while(n < 1);

t=n;

while(t!=0)
{
s = t%10;
t = t/10;
if(s>max)
{
max=s;
}
}

printf("Chu so lon nhat cua %d la %d",n,max);
return 0;
}
reply