[ create a new paste ] login | about

Link: http://codepad.org/9RHO1DxZ    [ raw code | output | fork | 3 comments ]

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

int main()
{
	int i, n;
	do
	{
	printf("\nNhap n(n > 0): ");
	scanf("%d", &n);
	  if(n <= 0)
	   {
		printf("\n N phai > 0. Xin nhap lai !");
	   }
	}while(n <= 0);
    i = 1;

	while(i <= n)
	{
		if(n % i == 0)
			printf("%4d", i);
			i++;
	}

	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 bangtran on Jan 22
// code by bangtran
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
int n, k;
cout << "Nhap so nguyen duong n: " ;
cin >> n;
k = n / 2;
cout << "Cac uoc so cua " << n << "la: ";
for (int i = 1; i <= k; i++)
{
if (n % i == 0)
cout << i << " ";
}

// END MAIN
cout << "\n\n <---Code By bangtran---> \n";
system("pause");
}

reply
posted by kokokouuty on Mar 25
bangtran : uoc chung cua 10 la 1,2,5,10 bạn thiếu ước là chính nó rồi( kq thiếu số 10)

reply
posted by bongrompa@gmail.com on Jun 2
#include "stdio.h"
#include "conio.h"
#include "math.h"
//-----------------------------
void souoc( designed n)
{ for( int i=1;i<=n;i++)
if(n%i==0)
printf("%d",i);
}
//----------------------------
void main()
{ clrscr();
designed n;
printf("\n nhap n: "); scanf("%d",n);
printf("\n cac uoc so la:");
souoc(n);
getch();
}
reply