[ create a new paste ] login | about

Link: http://codepad.org/hFIPSJXL    [ raw code | output | fork | 6 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;

	printf("\nCac uoc so le cua so %d la: ",n);
	while(i <= n)
	{
		if(n % i == 0)
		{
			if(i % 2 == 1)
			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 AndyzHoang on Jul 16
// Hoàng Tấn Phú Quốc
// Thuật toán của mình như sau
i=1;
while (i <= n)
{
if (n % i == 0 )
{
printf("%4d",i);
}
i+=2;
}

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

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

for(i=1;i<=n;i++)
{
if(n%i==0 & i%2==1)
{
printf("Uoc nguyen duong le cua %d la : %d\n",n,i);
}
}
return 0;
}
reply
posted by luongphongnhan on Oct 20
#include<iostream>
using namespace std;

int count(int a) {
int dem = 0;
for (size_t i = 1; i <= a; i++)
{
if (a%i == 0 && i%2 == 1)
{
dem += 1;
}
}
return dem;
}

int main(){
int so;
do
{
cout << "Moi nhap so n: ";
cin >> so;
if (so < 0) {
cout << "Moi nhap lai so:" << endl;
system("cls");
}
} while (so < 0);
cout << "So luong uoc so le cua so " << so << " la " << count(so) << endl;
system("pause");
return 0;
}
reply
posted by tranhieu on Dec 8
#include <iostream>
using namespace std;

int main ()
{
int n;
int mul=1;
cout <<"nhap so nguyen duong N = ";
cin >> n;
cout <<"cac uoc chung so le cua N la: ";
for (int i = 1;i <= n;i++)
{
if (n % i == 0&& i %2==1)
mul *= i;
}

cout << mul<<" ";
return 0;
}
reply
posted by quangdeptrai on Nov 28
#include <quangdeptrai>
using namespace std;
int main()
{

long a,b;
cin >>a >>b;
if (a>b) cout << "quang dep trai" ; else cout << "QUang thong minh ";

return 0;

}
reply
posted by 20223768 on Sep 9
#include <iostream>
using namespace std;
int main()
{
int n; cin >>n;
for (int i=1; i<=n; i++)
if(n%i==0 && i%2!=0) cout << i <<" ";
return 0;
}
reply