- Messages
- 1,529
- Reaction score
- 2
- Points
- 28
- Thread Starter
- #481
ano sample input mo para sa 2 array?
Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.
All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!
pa help naman po
http://*** BANNED LINK - DO NOT POST ***/aBQ6ACzT
need ko po output na Ascending Order
#include<stdio.h>
#include<conio.h>
main()
{
void read(int *,int);
void display(int *,int);
void sort(int *,int);
void mergelist(int *,int *,int *,int);
int a[5],b[5],c[10];
printf("Enter the elements for the first array \n");
read(a,5);
printf("Enter the elements for the second array \n");
read(b,5);
sort(a,5);
sort(b,5);
mergelist(a,b,c,5);
printf("The elements of merged list is \n");
display(c,10);
getch();
}
void read(int c[],int i)
{
int j;
for(j=0;j<i;j++)
scanf("%d",&c[j]);
fflush(stdin);
}
void display(int d[],int i)
{
int j;
for(j=i-1;j>=0;j--)[COLOR="Red"] // here is the error[/COLOR]
printf("%d ",d[j]);
printf("\n\n");
}
void sort(int arr[] ,int k)
{
int temp;
int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<k-i-1;j++)
{
if(arr[j]<arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
void mergelist(int a[],int b[],int c[],int k)
{
int ptra=0,ptrb=0,ptrc=0;
while(ptra<k && ptrb<k)
{
if(a[ptra] < b[ptrb])
{
c[ptrc]=b[ptrb];
ptrb++;
}
else
{
c[ptrc]=a[ptra];
ptra++;
}
ptrc++;
}
while(ptra<k)
{
c[ptrc]=a[ptra];
ptra++;ptrc++;
}
while(ptrb<k)
{
c[ptrc]=b[ptrb];
ptrb++; ptrc++;
}
}
Ganito po oh http://www.symbianize.com/attachment.php?attachmentid=764499&stc=1&d=1373451329
Then mag Add po ng void descend(int *,int);
yang picture sa taas sir Edit lang yan sa Paint
#include<stdio.h>
#include<conio.h>
main(){
void read(int *,int);
void display(int *,int);
void sort(int *,int);
void mergelist(int *,int *,int *,int);
void descend(int *,int);
int a[5],b[5],c[10];
printf("Enter the elements for the first array \n");
read(a,5);
printf("Enter the elements for the second array \n");
read(b,5);
sort(a,5);
sort(b,5);
mergelist(a,b,c,5);
printf("The elements of merged list is \n");
display(c,10);
printf("The Descending list: \n");
descend(c,10);
getch();
}
void read(int c[],int i){
for(int j=0;j<i;j++)
scanf("%d",&c[j]);
fflush(stdin);
}
void display(int d[],int i){
for(int j=0;j<i;j++)
printf("%d ",d[j]);
printf("\n\n");
}
void sort(int arr[] ,int k){
int temp;
for(int i=0;i<k;i++)
for(int j=0;j<k-i-1;j++)
if(arr[j]>arr[j+1]){
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
void mergelist(int a[],int b[],int c[],int k){
for(int i=0; i<k; i++)
c[i] = a[i];
for(int l=0, j=k; l<k, j<k*2; l++, j++)
c[j] = b[l];
sort(c,10);
}
void descend(int c[], int k){
for(int i=k-1; i>=0; i--){
printf("%d ", c[i]);
}
}
patambay para sa mga future assingment namin sa java
flowchart pa lang kasi kami ngayun eh
Sir Raymundpogi may project po kasi kami , nakakahiya mang magpatulong pero alam kong sisiw lan to para sa mga katulad nyo (EE student from FEU , di ko naman major yn at Comp. Engr. lan ang may kelangan nyan hanggang higher yr)
Bale po addition of binary ang project namin para sa microsoft visual studio 2010 (.c)
Mag iinput ng 5 binary numbers ang prof. namin kahit anu (binary 0,1) , halimbawa 0001110,0001110,1100,00011110,0101 tapos ang magiging output yung sagot nyan ng addition of binary , ganun lan po , sana matulungan nyo ako
Kakapalan ko na po ang mukha ko samahan nyo na rin po ng FLOWCHART after nyo magawa after kasi mapa run , ieexplain sya through FLOWCHART ,..
Salamat po talaga kung sino makatulong
package JCalculator;
import java.text.DecimalFormat;
import javax.print.DocFlavor;
public class NewJFrame extends javax.swing.JFrame {
double total1 = 0;
double total2 = 0;
double plusminus;
char math_operator;
int Decimal1;
public NewJFrame() {
initComponents();
}
private void getOperator(String btnText) {
math_operator = btnText.charAt(0);
total1 = total1 + Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
}
private void ClearActionPerformed(java.awt.event.ActionEvent evt) {
total2 = 0;
jTextField1.setText("");
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton1.getText());
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton5.getText());
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton2.getText());
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton3.getText());
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton4.getText());
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton6.getText());
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton7.getText());
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton8.getText());
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton8.getText());
}
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText() + jButton10.getText());
}
private void PlusActionPerformed(java.awt.event.ActionEvent evt) {
String button_text = Plus.getText();
getOperator(button_text);
}
private void EqualsActionPerformed(java.awt.event.ActionEvent evt) {
switch ( math_operator ) {
case '+':
total2 = total1 + Double.parseDouble(jTextField1.getText());
break;
case '-':
total2 = total1 + Double.parseDouble(jTextField1.getText());
break;
case '/':
total2 = total1 + Double.parseDouble(jTextField1.getText());
break;
case '*':
total2 = total1 + Double.parseDouble(jTextField1.getText());
break;
}
jTextField1.setText( Double.toString(total2) );
total1 = 0;
}
private void DecimalActionPerformed(java.awt.event.ActionEvent evt) {
if (Decimal1==0)
jTextField1.setText(jTextField1.getText()+Decimal.getText());
Decimal1 = 1;
}
private void PlusminusActionPerformed(java.awt.event.ActionEvent evt) {
plusminus=(Double.parseDouble(String.valueOf(jTextField1.getText())));
plusminus=plusminus*(-1);
jTextField1.setText(String.valueOf(plusminus));
}
private void SubtractActionPerformed(java.awt.event.ActionEvent evt) {
String button_text = Subtract.getText();
getOperator(button_text);
}
private void DivideActionPerformed(java.awt.event.ActionEvent evt) {
String button_text = Divide.getText();
getOperator(button_text);
}
private void MultiplyActionPerformed(java.awt.event.ActionEvent evt) {
String button_text = Multiply.getText();
getOperator(button_text);
}
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
Cast your double value to int when printing. Ie: (int)total
GUYS paturo naman dito kailangan na namin ksi gumawa nito until 12midnight pasahan c++ or java thanks
EXP5
Quick sort. It starts with choosing a partitioning element called the pivot. The elements will be divided according to the pivot, one part contains elements that are less than or equal to the pivot, the other part contains elements that are greater than the pivot. New pivots are chosen until arrays contain only 1 or 2 elements when necessary comparisons are performed.
Create a program that implements quick sort. Any programming language can be used. Create a function/method that uses the concept of quick sort. Pivot shall always be the first element in the array. Show the number of comparisons and the value of the set of elements per pass. Maximum number of elements is 15.