本文发表在 rolia.net 枫下论坛#include <stdio.h>
int EvenCounter(int number)
{
static int counter =0;
if (number % 2 == 0)
counter++;
return counter;
}
int Multiply(int number)
{
static int multipl = 1;
multipl *= number;
return multipl;
}
#define MAX_INPUT 20
int main()
{
register int even = 0;
int input =0;
register long multiply = 0;
int i;
for (i=0; i < MAX_INPUT; i++)
{
printf("Please input the <%d> integer number:",i+1);
scanf("%d", &input);
even = EvenCounter(input);
multiply = Multiply(input);
}
printf("Statistics:\n\n");
printf("Even numbers:%d\n", even);
printf("Odd numbers:%d\n", MAX_INPUT - even);
printf("The percentage of even numbers: %d%\n", even*(100/MAX_INPUT));
printf("The percentage of odd numbers: %d%\n", 100- even*(100/MAX_INPUT));
printf("Multiplication:%d\n", multiply);
return 0;
}
lab1.exe': Loaded 'C:\Wendy\SENECA\PRG 255 Course\PRG255D\lab1\Debug\lab1.exe', Symbols loaded.
'lab1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
The program '[3136] lab1.exe: Native' has exited with code 0 (0x0).更多精彩文章及讨论,请光临枫下论坛 rolia.net
int EvenCounter(int number)
{
static int counter =0;
if (number % 2 == 0)
counter++;
return counter;
}
int Multiply(int number)
{
static int multipl = 1;
multipl *= number;
return multipl;
}
#define MAX_INPUT 20
int main()
{
register int even = 0;
int input =0;
register long multiply = 0;
int i;
for (i=0; i < MAX_INPUT; i++)
{
printf("Please input the <%d> integer number:",i+1);
scanf("%d", &input);
even = EvenCounter(input);
multiply = Multiply(input);
}
printf("Statistics:\n\n");
printf("Even numbers:%d\n", even);
printf("Odd numbers:%d\n", MAX_INPUT - even);
printf("The percentage of even numbers: %d%\n", even*(100/MAX_INPUT));
printf("The percentage of odd numbers: %d%\n", 100- even*(100/MAX_INPUT));
printf("Multiplication:%d\n", multiply);
return 0;
}
lab1.exe': Loaded 'C:\Wendy\SENECA\PRG 255 Course\PRG255D\lab1\Debug\lab1.exe', Symbols loaded.
'lab1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'lab1.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
The program '[3136] lab1.exe: Native' has exited with code 0 (0x0).更多精彩文章及讨论,请光临枫下论坛 rolia.net