If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
It's just I have an iPhone 4 that iOS 4 already slowed down a bit so I'm not looking forward to the epic slow down that's gonna come with ios6 , at least my upgrade is in late December I might pick my self up a 5 as a birthday present to my self
Get a dumb phone. ALWAYS fasssssst, especially if you can pick up the ones with a green monochrome screen! On top of that, when in pocket, gives the small dudes a much needed boost in confidence!
//prototype of functions
void show( const unsigned a[], unsigned elements ); //prototype of function show
double sum( const double a[], unsigned elements ); //prototype of function sum
double product( const double a[], unsigned elements );//prototype of function product
double maxValue( const double a[], unsigned elements );//prototype of function maxValue
unsigned maxIndex( const double a[], unsigned elements );//prototype of function maxIndex
void call( void f( double x ), const double a[], unsigned elements );//prototype of function call
bool decreasing( const double a[], unsigned elements );//prototype of function decreasing
void choose( double result[], const bool which[], const double a[],const double b[], unsigned elements );//prototype of function choose
void f(double x);//prototype of function f
//Main function
int main()
{
//////////////////////////////////////////////////////////////////////
///////////////////////////TEST ALL FUNCTIONS/////////////////////////
//////////////////////////////////////////////////////////////////////
unsigned a[] = {2, 4, 6, 8};//array a
double aa[] = {2, 4, 6, 8}; //array aa
double b[] = {8, 5, 4, 2};//array b
double choosea[]= {1.1, 2.2, 3.3, 4.4};//array a for test function choose
double chooseb[]= {-10.0, -20.0, -30.0, -40.0};//array b for test function choose
double chooseresult[10];//array result for test function choose
bool choosewhich[]= {true, false, true, false};//array choosewhich for test function choose
show(a,4);//call function show
printf("\nSum of all elements is %.2lf",sum(aa,4));//call function sum
printf("\nProduct of all elements is %.2lf",product(aa,4));//call function product
printf("\nThe value of the largest element is %.2lf",maxValue(aa,4));//call function maxValue
printf("\nThe index of the largest element is %d",maxIndex(aa,4));//call function maxIndex
call(f,aa,4);//call function call
if(decreasing(aa,4)==false){//check if array is decreasing
printf("\nThe elements of the array are already in decreasing order: false");
}else{
printf("\nThe elements of the array are already in decreasing order: true");
}
if(decreasing(b,4)==false){
printf("\nThe elements of the array are already in decreasing order: false");
}else{
printf("\nThe elements of the array are already in decreasing order: true");
}
choose(chooseresult,choosewhich,choosea,chooseb,4) ;//call function choose
printf("\nResult: ");
for(int i=0;i<4;i++){
if(i<3){
printf("%.2lf,",chooseresult[i]);
}else{
printf("%.2lf",chooseresult[i]);
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////END TEST////////////////////////////////
//////////////////////////////////////////////////////////////////////
getch();
return 0;
}
//function show
void show( const unsigned a[], unsigned elements ){
printf("[%d]:",elements);
for(int i=0;i<elements;i++){
if(i<elements-1){
printf("%d,",a[i]);
}else{
printf("%d",a[i]);
}
}
}
//caluclate sum
double sum( const double a[], unsigned elements ){
double sumofelements=0;
for(int i=0;i<elements;i++){
sumofelements+=a[i];
}
return sumofelements;//Return the sum of all the array elements.
}
//caluclate product
double product( const double a[], unsigned elements ){
double productofelements=1;
for(int i=0;i<elements;i++){
productofelements*=a[i];
}
return productofelements;//Return the product of all the array elements. The empty product is defined to be 1
}
//find max Value int array
double maxValue( const double a[], unsigned elements ){
double maxValueoflements=a[0];//set a[0] as maxValue
for(int i=0;i<elements;i++){
if(a[i]>maxValueoflements){
maxValueoflements=a[i];
}
}
return maxValueoflements; //return the value of the largest element. If there is no largest element
}
//find maxIndex
unsigned maxIndex( const double a[], unsigned elements ){
double maxValueoflements=a[0];//set a[0] as maxValue
unsigned maxIndex=0;//declare variable maxIndex
for(int i=0;i<elements;i++){
if(a[i]>maxValueoflements){
maxIndex=i;
}
}
return maxIndex; //Return the index of the largest element.
}
//call function
void call(void f(double x), const double a[], unsigned elements ){
printf("\nElements of array: ");
for (int i=0;i<elements;i++){
f(a[i]);
}
}
//f function
void f(double x){
printf("%0.2f,",x);
}
//decreasing function
bool decreasing( const double a[], unsigned elements ){
bool isdecreasing=false;
int countforincr=0;
int countfordecreasing=0;
for (int i=0;i<elements-1;i++){
if (a[i]<=a[i+1]) {countforincr++;}
if (a[i]>=a[i+1]) {countfordecreasing++;}
}
//check if array is in increasing order
if (countforincr==elements-1 && countfordecreasing==0) {
isdecreasing=false;
}
//check if array is in decreasing order
if (countfordecreasing==elements-1 && countforincr==0){
isdecreasing=true;
}
//check if array is not in decreasing or in increasing order
if (countfordecreasing>0 && countforincr>0){
isdecreasing=false;
}
//Just return whether the elements of the array are already in decreasing order
return isdecreasing;//retun result
}
//function choose
void choose( double result[], const bool which[], const double a[],const double b[], unsigned elements ){
printf("\nArray a: ");
for(int i=0;i<elements;i++){
if(i<elements-1){
printf("%.2lf,",a[i]);
}else{
printf("%.2lf",a[i]);
}
}
printf("\nArray b: ");
for(int i=0;i<elements;i++){
if(i<elements-1){
printf("%.2lf,",b[i]);
}else{
printf("%.2lf",b[i]);
}
}
for(int i=0;i<elements;i++){
if(which[i]==true){
result[i]=a[i];
}else{
result[i]=b[i];
}
}
}
took me 2 weeks, still need to fine tune it. :(
「'89 BMW 325is | '02 Mitsubishi Montero Limited | '2005 GMC Sierra 2500 Duramax | 2007 BMW M5 」
「my feedback thread」
Comment