좋아, 얘들 아, 이건 숙제가 되었어. 제출 되었으니 나는 78 :을 받았다. 교수님이 내 이메일을 보내 주셨습니다. 지금 여기 있습니다.분수 감소 C 프로그램
코드의 첫 번째 부분은 분수를 가장 낮은 형식으로 줄이기로되어 있으며 최대 공통 분모가 10을 초과하는 경우를 제외하고는 작동합니다. 이것은 C 클래스에 대한 소개이며 경험이 거의 없습니다. C와 그 특이성. 어떤 도움 /지도/아이디어가있는 GCD 문제 ..? 당신은 무조건 당신의 감소 루프에 break
, 그래서 한 번 이상 당신이 결코 루프 더
#include <stdio.h>
int main (void)
{
int num;
int den;
int x;
int y;
int i;
int a;
int n;
int w;
int j;
printf("\n *************Question 1 *************** \n");
printf("Please enter the numerator: ");
scanf("%d", &num);
printf("Please enter the denominator: ");
scanf("%d", &den);
printf("The fraction entered is: \n %d/%d \n", num, den);
if (num > den)
x=den;
else
x=num;
for(i=x; i>=1; i--){
if(num % i == 0 && den % i == 0){
printf("This fraction can be reduced! \n");
num = num/i;
den = den/i;
printf("The reduced fraction is %d/%d \n \n", num, den); break;}
else
printf("This fraction cannot be reduced any further \n");
break;
}
printf("\n ***************Question 2****************** \n");
printf("Please enter a number and I will print the even squares up to your input ");
scanf("%d", &n);
for (w=1; w<=n; w++)
if (w*w%2 == 0 && w*w <= n)
printf("%d \n", w*w);
printf("Question 5 test... please enter 10.3 then 5 then 6 ");
scanf("%d%f%d",&i,&x,&j);
printf("%d %f %d \n",i,x,j);
return 0;
}
2. 당신은에 대한 + 1 얻을 명제)가 숙제이고 우리에게 유클리드에 의해 설명되었다 b) 귀하 뭔가를 시도했다. 그러나 다른 코드를 들여 쓰기를하십시오 –
아마도 코드의 가독성이 낮아서 22 퍼센트의 추가 포인트를 많이 잃어 버렸을 것입니다. 가독성의 중요성을 절대로 과소 평가하지 마십시오. 또한 변수의 이름을 더 의미있게 지정하는 것이 좋을 것이며 코드가 수행해야하는 작업이나 수행해야 할 작업을 나타내는 주석이 전혀 없습니다. –