[ create a new paste ] login | about

Link: http://codepad.org/oT3TjEbl    [ 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
#include<stdio.h>
#include<conio.h>

int main()
{
	int S = 0;
	int n = 0;
	while(S < 10000)
	{
		n++;
		S = S + n;
	}
	printf("\nTong la %d", S);
	printf("\nSo n la %d", n);
	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 yonnon on Jul 12
#include<bits/stdc++.h>

using namespace std;
int main(){
int n=10000;
int S=0;
for(int i=1 ; i <=n;++i ){
S += i;
if(S>n){
cout<<i<<
endl;
return 0;
}
}

}

reply
posted by luongphongnhan on Oct 22
#include<iostream>
using namespace std;
int main() {
int soMin;
int tong = 0;
for (int i = 0; i < 10000; i++)
{
tong += i;
if (tong > 10000) {
soMin = i;
cout << "Gia tri min la: " << soMin << endl;
break;
}
}
system("pause");
return 0;
}
reply