The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
please convert the below program into shell script mail2sant Shell Programming and Scripting 3 04-10-2008 09:39 AM
convert the below perl sript to shell script mail2sant Shell Programming and Scripting 1 04-04-2008 02:36 PM
Shell script to convert to Title case SankarV UNIX for Advanced & Expert Users 5 06-22-2007 08:45 AM
Convert shell script for looping le0pard13 Shell Programming and Scripting 4 06-07-2007 08:42 PM
C Shell Script to convert a number into minutes Ringo Shell Programming and Scripting 1 08-07-2003 02:24 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-11-2007
domain's Avatar
domain domain is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 5
convert cpp program to c shell script ?

Hi guys
I tried to convert this c++ code to c shell script but there are some bugs and I don't know how to solve it.
This code prints the three variables in decreasing order:

Code:
int main()
{
int x,y,z;
cin >> x >> y >>z;

if ( x < y )
	if ( x < z )
		if ( y < z )
			cout << x <<"  " << y <<"  "<<  z << endl;
		else
			cout << x <<"  "<<  z <<"  "<<  y << endl;
	else
		cout << z <<"  "<< x <<"  "<< y << endl;
else
	if ( y < z )
		if ( x < z )
			cout << y <<"  "<< x <<"  "<< z << endl;
		else
			cout << y <<"  "<< z <<"  "<< x << endl;
	else
		cout << z <<"  "<< y <<"  "<<x << endl;

return 0;

}
Here is my try:


Code:
#!/bin/csh

if ( $1 < $2 ) then
	if ( $1 < $3 ) then
		if ( $2 < $3 ) then
			echo $1"  "$2"  "$3
		else
			echo $1"  "$3"  "$2
	else
		echo $3"  "$1"  "$2
else
	if ( $2 < $3 ) then
		if (  $1 < $3 ) then
			echo $2"  "$1"  "$3
		else
			echo $2"  "$3"  "$1
	else
		echo $3"  "$2"  "$1
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0