Skip to content

Instantly share code, notes, and snippets.

@tina1998612
Created November 1, 2017 16:18
Show Gist options
  • Save tina1998612/8df8c93b162df02e187feb01d251e5ea to your computer and use it in GitHub Desktop.
Save tina1998612/8df8c93b162df02e187feb01d251e5ea to your computer and use it in GitHub Desktop.
#include <iostream>
#include <sstream>
using namespace std;
struct Node
{
char data;
Node* next;
};
void displayList(Node* head)
{
while(head != NULL)
{
printf("%c", head->data);
head = head->next;
}
printf("\n");
}
int main()
{
float f;
while(cin>>f)
{
stringstream ss;
ss << f;
string s = ss.str();
Node* head = NULL;
Node* p = new Node;
for(int j=s.length()-1;j>=0;j--){
p->data = s[j];
p->next = head;
if(head == NULL) cout<<"yes"<<endl;
head = p;
}
displayList(head);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment