Jump to content
Sign in to follow this  
edril

Maks And Min

Recommended Posts

owh c++ and c language die lebih kurang je ek..aku beginer n tak bape tau sangatpun beza dua language ni.So lau aku nak convert coding c++ jadi c camne eh?kena define pape ke?

Share this post


Link to post
Share on other sites
sori koz terbuat topik baru.akupun baru je join forum neh......koding c++ dengan c kan lain kan.macam contoh.dalam program c, untuk papar output kita guna arahan printf("xyz"); ,tapi dalam c++ die tak guna printf kan .senang cite kat bawah nie ade kod yang aku dapat tapi guna c++....

#include <iostream>
using namespace std;

const SIZE = 7;

int minOrMax(int arr[], bool isMin){
int value = arr[0];
for(int i=0; i<SIZE; ++i){
value = isMin? (arr[i]< value? arr[i]: value) : (arr[i]> value? arr[i]: value);
}
return value;
}

int main(){
int x[SIZE] = {9,15,30,8,10,6,21};

cout<<minOrMax(x,true) << "\n";
cout<<minOrMax(x, false) << "\n";
return 0;

}


skang neh aku nak tulis semula koding ni dalam language c.so camne eh....leh tolong....tulis kod yang baru n explain la ckt

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...