फ़ाइल में सामग्री जोड़ना
फ़ाइलों के साथ काम करने के लिए कई मोड उपलब्ध हैं:
मोड | कार्य | उदाहरण |
---|---|---|
| पढ़ना (डिफ़ॉल्ट) |
|
| लिखना |
|
| जोड़ना |
|
| पढ़ना + लिखना |
|
| बनाना (यदि पहले से मौजूद है तो त्रुटि) |
|
कंप्यूटर पर विभिन्न फ़ाइलें मौजूद हैं। आपका काम उनमें कुछ पंक्तियाँ जोड़ना है।
इनपुट में 2 लाइनें होती हैं। पहली लाइन फ़ाइल का नाम है। दूसरी लाइन वह सामग्री है जिसे हम उस फ़ाइल में जोड़ना चाहते हैं।
प्रोग्राम को पहले निर्दिष्ट पंक्ति को फ़ाइल में जोड़ना होगा और फिर फ़ाइल की पूरी सामग्री को प्रिंट करना होगा।
इनपुट | doc.txt (प्रारंभिक सामग्री) | आउटपुट | doc.txt (अंतिम सामग्री) |
---|---|---|---|
doc.txt This is the second line | This is the first line | This is the first line This is the second line | This is the first line This is the second line |
इनपुट | empty.txt (प्रारंभिक सामग्री) | आउटपुट | empty.txt (अंतिम सामग्री) |
---|---|---|---|
empty.txt Adding some content | Adding some content | Adding some content |
इनपुट | multiline.txt (प्रारंभिक सामग्री) | आउटपुट | multiline.txt (अंतिम सामग्री) |
---|---|---|---|
multiline.txt The final line! | This is some very very long document with many lines of text… | This is some very very long document with many lines of text… The final line! | This is some very very long document with many lines of text… The final line! |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB