The UNIX and Linux Forums  

Go Back   De Unix-en Linux Forum > Top Forums > Hoog Niveau Programmering
.
google unix.com



Hoog Niveau Programmering Post vragen over C, C + +, Java, SQL, en andere programmeertalen hier.

Meer UNIX en Linux Forum Onderwerpen Misschien vindt u Helpful
Draad Thread Starter Forum Antwoorden Last Post
Een programma voor het opsporen van de uitvoering van een ander programma jiten_hegde Hoog Niveau Programmering 3 08-19-2008 06:26
Hoe te schrijven naar stdin van een ander programma (programma A -> [stdin] programma B) vvaidyan UNIX voor Dummies Questions & Answers 3 08-02-2008 06:21 PM
Hoe te schrijven naar stdin van een ander programma (programma A -> [stdin] programma B) vvaidyan Hoog Niveau Programmering 1 04-30-2008 02:44 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 Zoeken in deze Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-24-2007
namishtiwari namishtiwari is offline Forum Advisor  
Geregistreerde gebruiker
  
 

Join Date: Aug 2007
Locatie: Bangalore
Posts: 377
Goede c + + Programma

Hi Guru's
Ik schreef een shell script enkele dagen terug.
Ik wil dit script te vertalen naar een C + + program.I hulp nodig van je guys.I nog nooit gedaan elke programmeren in C + + til nu.


Code:
#!/usr/bin/ksh

inpFile=$1
outFile="$HOME/Output.txt"
errFile="$HOME/Error.txt"
dupFile="$HOME/Duplicate.txt"
tmpFile1=sample1.txt
tmpFile2=sample2.txt
sortFile=sortfile.txt

TOTAL_FILEDS=9
COUNT=1
PRINT_FLAG=0
LINE_NO=1
check_lines=0
rm -f $outFile $errFile $dupFile
sort $inpFile | uniq -d > $dupFile
#sort $inpFile | uniq -d | sed "s/$/& : Duplicate/g" >> $errFile
for line in $(cat $inpFile)
do
  	count_fields=$(echo $line | sed "s/00,*//g;s/,$//g" | wc -c)
	echo "count_fields is: $count_fields"
	cnt_flds1=$(echo $line | cut -d',' -f1-9 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds1 is : $cnt_flds1"
	cnt_flds2=$(echo $line | cut -d',' -f10-18 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds2 is : $cnt_flds2"
	cnt_flds3=$(echo $line | cut -d',' -f19-27 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds3 is : $cnt_flds3"
	if [[ $count_fields -eq 45 && $cnt_flds1 -eq 15 && $cnt_flds2 -eq 15 && $cnt_flds3 -eq 15 ]]
	then
            	PRINT_FLAG=0

		echo $line | cut -d',' -f1-9 > $sortFile
		echo $line | cut -d',' -f10-18 >> $sortFile
		echo $line | cut -d',' -f19-27 >> $sortFile

		while [[ $COUNT -le $TOTAL_FILEDS ]]
		do
                  	cut -d',' -f$COUNT $sortFile | grep -v 00 > $tmpFile1
			cut -d',' -f$COUNT $sortFile | grep -v 00 | sort > $tmpFile2

			diff $tmpFile1 $tmpFile2 > /dev/null
			if [[ $? -eq 1 || ! -s $tmpFile1 ]]
			then
                            	PRINT_FLAG=1
				break
fi
		COUNT=$((COUNT+1))
		done
		echo "Value of print flag is : $PRINT_FLAG"
		if [[ $PRINT_FLAG -eq 0 ]]
		then
			echo "$line : SUCCESS" >> $outFile
		else
			echo "$line : ERROR in $COUNT" >> $errFile
		fi
	else
		echo "$line : Out of Scope"  >> $errFile
	fi
	COUNT=1
	check_lines=$((check_lines+count_fields))
	if [[ $LINE_NO -eq 6 ]]
	then
		LINE_NO=0
		if [[ $check_lines -eq 270 ]]
		then
			echo " **** Success A Strip has 90 digits"
		else
			echo "----- Error,Check the above -----"
		fi
		check_lines=0
	fi
	LINE_NO=$((LINE_NO+1))
done
rm -f $tmpFile1 $tmpFile2 $sortFile
exit 0

De input bestand ----

Code:
00,11,21,00,00,55,00,73,83,07,00,22,39,43,00,66,00,00,00,15,00,00,44,58,67,00,87
02,14,24,30,00,00,00,70,00,00,00,00,32,47,50,60,74,00,04,16,27,38,00,00,00,00,89
00,00,00,00,42,52,61,71,86,01,00,29,33,00,59,00,75,00,03,19,00,00,45,00,68,00,88
00,13,20,31,00,00,64,76,00,05,00,00,35,41,56,00,00,81,00,00,28,00,00,57,65,79,90
06,10,00,36,40,00,00,00,80,00,12,25,00,00,51,62,72,00,09,00,00,37,49,00,69,00,84
00,17,23,00,46,53,00,77,00,08,00,00,34,00,54,00,78,82,00,18,26,00,48,00,63,00,85
00,14,23,39,00,00,60,00,87,02,00,28,00,41,50,00,75,00,03,15,00,00,44,00,68,00,90
00,16,25,35,00,53,00,71,00,08,00,00,36,40,00,62,00,88,00,00,27,37,00,58,64,78,00
05,10,00,00,48,52,00,73,00,00,00,24,31,00,57,66,00,81,07,17,00,00,49,00,00,79,85
00,00,20,33,00,00,63,70,80,06,12,00,34,42,56,00,00,00,00,00,29,00,00,59,69,74,86
04,13,00,32,43,00,65,00,00,00,18,22,00,00,55,00,72,84,09,00,00,38,47,00,67,00,89
01,11,21,00,00,51,00,76,00,00,00,26,30,45,54,00,00,82,00,19,00,00,46,00,61,77,83

Bedankt

Laatst gewijzigd door vino; op 08.24.2007 09:48.. Reden: Toegevoegd code tags.
 

Bladwijzers

Thread Tools Zoeken in deze Thread
Zoeken in deze Thread:

Uitgebreid zoeken
Display Modes Beoordeel deze draad
Beoordeel deze draad:

Posting Regels
Jij mag niet Post Nieuwe threads
Jij mag niet na antwoorden
Jij mag niet post attachments
Jij mag niet bewerk uw berichten

BB code is Aan
Smilies zijn Aan
[IMG] code Aan
HTML-code is Uit
Trackbacks zijn Aan
Pingbacks zijn Aan
Refbacks zijn Aan




Alle tijden zijn GMT -4. Het is nu 02:17 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Vertalingen Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
De Unix-en Linux Forums Copyright © 1993-2009. Alle rechten Reserved.Ad Beheer door RedTyger

Content Relevante URL's door vBSEO 3.2.0