C,
pasted
on Sep 6:
|
#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:
|
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
posted by
yonnon
on Jul 12
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cout << "Enter your sentence: ";
cin >> n;
int S=0;
for(int i=1; i<=n; ++i){
S+=i;
if(S>n){
cout<<i-1<<
endl;
return 0;
}
}
return 0;
}
reply
posted by
luongphongnhan
on Oct 22
using namespace std;
int main() {
int n;
cout << "Enter your sentence: ";
cin >> n;
int S = 0;
for (int i = 1; i <= n; ++i) {
S += i;
if (S > n) {
cout << i - 1 <<
endl;
return 0;
}
}
system("pause");
return 0;
}
reply