Notes
Notes - notes.io |
3 cifre si se termina cu un numar de 3 cifre
#include<iostream>
#include<fstream>
using namespace std;
int nr,x,y;
int main()
{
ifstream in("numere.in");
while(in>>x&&(x<100||x>999));
nr=1;
while(in>>x)
if(x>99&&x<1000)
{
nr++;
y=nr;
}
else
nr++;
cin>>y;
in.close();
return 0;
}
Explicarea metodei:
Se citesc valorile din fisierul text pana la primul numar de 3 cifre. Odata ce acesta este gasit, variabila nr ia valoarea 1. Se citesc valori din fisierul text in
variabila x si se verifica daca este de 3 cifre. Odata ce este gasit un numar de 3 cifre, variabila nr creste, si y ia valoarea lui nr. Daca valoarea citita nu este de
3 cifre nr creste, dar lui y nu i se schimba valoarea. Se afiseaza variabila y si se inchide fisierul text.
Eficienta:
Numerele din fisier au fost accesate o singura data la citire. Se fac comparatii si atribuiri simple.
Instructiunile se pot executa de maxim 1.000.000 de ori.
Memorie:
Se folosesc variabile simple x,y,nr. In Code::Blocks se folosesc 4 bytes la o singura variabila -> 12 bytes la toate variabilele.
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team