phoenix ([info]phoenix) wrote on May 3rd, 2006 at 01:59 pm
[Error: Irreparable invalid markup ('<iostream.h>') in entry. Owner must fix manually. Raw contents below.]

Jaa, tavu piemeeru iekopeejot, viss straadaa pareizi. Bet lidzko to pashu meeghinu izdariit ar savu piemeru, viss atkal ir shkjiibi. Snaak, ka kaut kur citur laikam ir probleema. JA sanaak laika, uzmet aci. I tka aviss ir taapat ka tev, bet nestraadaa. varbuu tam getline ir kaukaadi konkreeti nosacijumi un vinjsh to masivu sakropljo?


#include <iostream.h>
#include <fstream.h>
using namespace std;

int main () {
ifstream IN;
ofstream OUT;
char char_masivs[100];
int summa;

IN.open("vid.in", ios::in); //failaa atrodas kaut vai tikai viena virkne ar 10 cipariem (piem, 1234567892)
OUT.open("vid.out", ios::out);

while (!IN.eof()) {
IN.getline(char_masivs,11);
cout <<char_masivs<<endl; //parbaudu vai no faila ielasijis pareizi
for (int i = 0; i < 9; i++){
if ((char_masivs[i] > '0') && (char_masivs[i] < '9')) {
summa = summa + char_masivs[i] - '0'; // summa + simbola_skaitliska_vertiba
}
}
cout << "Masivs ir: " << char_masivs << " Taja ciparu summa ir:" << summa << endl; <-- un neatgriezh korektu veertiibu!
}

IN.close();
OUT.close();

system ("PAUSE");
return 0;
}
 
( Read comments )
Post a comment in response:
From:
( )Anonymous- this user has disabled anonymous posting.
Username:
Password:
Subject:
No HTML allowed in subject
  
Message:

Notice! This user has turned on the option that logs your IP address when posting.