呜~ 作业不会做!!

最初由 血红的残阳 发布
I am damn busy today, afraid not be able to help much.
Should have asked for help earlier...

Do you have to hand it in today? if so, I might be able to do it after 8pm, but definitely not right now.
Sorry if that does not help...

that doesn't help, but thanks anyways~ :rolleyes:
 
C++的话,我可以帮你。。。不好意思~~
 
最初由 Bleuet 发布
C++的话,我可以帮你。。。不好意思~~

是C, 你可以帮??
PART B 的两题, 你会吗??
 
i can't understand that code that u wrote, probably i can't help u, when does it due?
 
最初由 Bleuet 发布
i can't understand that code that u wrote, probably i can't help u, when does it due?

5pm~~ :crying: :crying:
 
#include <stdio.h>
#include <stdlib.h>

void outputNormal( unsigned int output);
void outputData( char format, unsigned int output );
void outputWithCharacter( char format, unsigned int output );
void outputDecimal( int numberOfDecimal, unsigned int output );
int getNumberOfDigit( unsigned int number );
int getNthDigit( int position, unsigned int number );
void funny(char format, unsigned int output);
int main()
{
unsigned int output;
char format;

printf("Please enter the Format Character: ");
scanf("%c", &format );

printf("Please enter the output number: ");
scanf("%d", &output);
outputData( format, output );
}//end of main

void outputData(char format, unsigned int output)
{
if ( (format == ',') || (format == ' ') )
{
outputWithCharacter( format, output );
}
else if ((format == 'N')||(format == 'n'))
{
outputNormal(output);
}
else if (( format >= 49 ) /*ascII code 1 */
&& (format <= 57) /*ascII code 9 */ )
{
outputDecimal( (format - 48), output);
}
else
{
printf("Incorrect format code");
}
}//end of main

void outputNormal( unsigned int output )
{
printf("%d", output);
}//end of outputNormal

void outputWithCharacter( char format, unsigned int output )
{
unsigned int count;
int numberOfCharacters;

numberOfCharacters = getNumberOfDigit( output );
for( count = numberOfCharacters; count > 0; count -- )
{
printf("%d", getNthDigit(count,output));
if( ((count%3) == 1)&& (count > 1) )
{
printf("%c", format);
}
}//end of for loop
}//end of outputWithCharacter

void outputDecimal( int numberOfDecimal, unsigned int output )
{
int count;
printf("%d", output );
printf(".");
for( count = 0; count < numberOfDecimal; count ++ )
{
printf("0");
}
}//end of outputDecimal

int getNumberOfDigit( unsigned int number )
{
int numberOfDigit = 0;
unsigned int temp = number ;
while( temp > 0 )
{
temp = temp /10;
numberOfDigit = numberOfDigit + 1;
}
return numberOfDigit;
}//end of getNumberOfDigit

int getNthDigit( int position, unsigned int number )
{
int temp = number;
int tempHolder = 0;
int count;

for( count = 0 ; count < position; count ++ )
{
tempHolder = temp;
temp = temp /10;
}
temp = temp * 10;
return tempHolder - temp;
}//end of getNthDigit
 
你刚做的?
还是你也上102?? :D
 
后退
顶部
首页 论坛
消息
我的