Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <conio.h>
- #include <string>
- #include <cstdlib>
- #include <fstream>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- using namespace std;
- int main(int argc, char *argv[]) {
- int i,n=0,e=0,a;
- string ciag;
- ciag = "2 3 4 5 6 7 , 3 5 9";
- char *tab1 = new char [ciag.length()];
- cout<<"Tablica znakow do przecinka: "<<endl;
- for (i=0;i<ciag.length();i++){
- if(ciag[i]==','){break;}
- else
- if(ciag[i]!=' '){
- tab1[n]=ciag[i];
- cout<<tab1[n];
- n++;
- }
- }
- cout<<endl;
- //okreslenie pozycji przecinka -1
- for (i=0;i<ciag.length();i++){
- if(ciag[i]==',') {
- a=i;
- }
- }
- char *tab2 = new char [ciag.length()];
- cout<<"Tablica znakow od przecinka: "<<endl;
- for (i=a+2;i<ciag.length();i++){
- if(ciag[i]!=' '){
- tab2[e]=ciag[i];
- cout<<tab2[e];
- e++;
- }
- }
- //porownanie
- fstream o ("liczby.txt") ;
- cout<<endl;
- for (e=0;e<ciag.length();e++) {
- for (n=0;n<ciag.length();n++){
- if( tab1[n]== tab2[e] ){
- cout<<tab2[e];
- o<<tab2[e];
- }
- }
- }
- o.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment