[ create a new paste ] login | about

Link: http://codepad.org/uxlv6nLk    [ raw code | output | fork | 2 comments ]

C, pasted on Sep 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<conio.h>

int main()
{
	int N, m, S;
	printf("\nNhap N: ");
	scanf("%d", &N);

	S = 0;
	m = 0;
	do
	{
		m = m + 1;
		S = S + m;
	}while(S + m + 1 < N);
	printf("\nSo nguyen duong m la %d", m);
	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 kawasakikute123@gmail.com on Nov 5
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long int i , n , S = 0 , max = 0 ;
cout<<" xin moi ban nhap so n"<<endl;
cin>>n;
for( i = 1 ; i<=n ; i++ )//that su thi cai i<=n chi la cai em su dung de cho lenh for chay duoc thoi , nhung cho em hoi code cua em dung khong a :(((
{
S = S + i ;
if(S<n)
{
if(i >= max )
{
max = i ;
}
}

}
cout<<max<<endl;
return 0;
}
reply
posted by kawasakikute123@gmail.com on Nov 5
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main()
{
long int i , n , S = 0 ;
cout<<"xin moi ban nhap so n"<<endl;
cin>>n;
for( S = 0 ; S<n ; S = S + i)
{
i++;

}
cout<<"vay so long nhat la: "<<i-1<<endl;
return 0;
}// con` cai nay` em phat trien y tuong dua tren bai : Tim` m nho nhat khi: S = 1 + 2 + 3 + ... + m > n
reply