Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <list>

using namespace std;

list<string> ans;

int main(void)
{
	list<string> pat[31];
	list<string>::iterator it;
	int n;
	char str[100];
	
	pat[0].push_back("");
		pat[1].push_back("1");
		
	for (int i = 2; i <= 30; i++){
		for (int j = 0; j < i; j++){
			sprintf(str, "%d ", i - j);
			for (it = pat[j].begin(); it != pat[j].end() && atoi(it->c_str()) > i - j; ++it);
			for (; it != pat[j].end(); ++it){
				pat[i].push_back(str + *it);
			}
		}
	}
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
			printf("%s\n", it->c_str());
		}
		
	}
	return (0);
}

Compiler output:
a.cc:7:6: error: 'string' was not declared in this scope
    7 | list<string> ans;
      |      ^~~~~~
a.cc:4:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    3 | #include <list>
  +++ |+#include <string>
    4 | 
a.cc:7:12: error: template argument 1 is invalid
    7 | list<string> ans;
      |            ^
a.cc:7:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:11:14: error: 'string' was not declared in this scope
   11 |         list<string> pat[31];
      |              ^~~~~~
a.cc:11:14: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:11:20: error: template argument 1 is invalid
   11 |         list<string> pat[31];
      |                    ^
a.cc:11:20: error: template argument 2 is invalid
a.cc:12:20: error: template argument 2 is invalid
   12 |         list<string>::iterator it;
      |                    ^
a.cc:12:32: error: expected initializer before 'it'
   12 |         list<string>::iterator it;
      |                                ^~
a.cc:16:16: error: request for member 'push_back' in 'pat[0]', which is of non-class type 'int'
   16 |         pat[0].push_back("");
      |                ^~~~~~~~~
a.cc:17:24: error: request for member 'push_back' in 'pat[1]', which is of non-class type 'int'
   17 |                 pat[1].push_back("1");
      |                        ^~~~~~~~~
a.cc:22:30: error: 'it' was not declared in this scope; did you mean 'i'?
   22 |                         for (it = pat[j].begin(); it != pat[j].end() && atoi(it->c_str()) > i - j; ++it);
      |                              ^~
      |                              i
a.cc:22:42: error: request for member 'begin' in 'pat[j]', which is of non-class type 'int'
   22 |                         for (it = pat[j].begin(); it != pat[j].end() && atoi(it->c_str()) > i - j; ++it);
      |                                          ^~~~~
a.cc:22:64: error: request for member 'end' in 'pat[j]', which is of non-class type 'int'
   22 |                         for (it = pat[j].begin(); it != pat[j].end() && atoi(it->c_str()) > i - j; ++it);
      |                                                                ^~~
a.cc:23:32: error: 'it' was not declared in this scope; did you mean 'i'?
   23 |                         for (; it != pat[j].end(); ++it){
      |                                ^~
      |                                i
a.cc:23:45: error: request for member 'end' in 'pat[j]', which is of non-class type 'int'
   23 |                         for (; it != pat[j].end(); ++it){
      |                                             ^~~
a.cc:24:40: error: request for member 'push_back' in 'pat[i]', which is of non-class type 'int'
   24 |                                 pat[i].push_back(str + *it);
      |                                        ^~~~~~~~~
a.cc:37:33: error: template argument 2 is invalid
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                 ^
a.cc:37:44: error: expected ';' before 'it'
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                            ^~~
      |                                            ;
a.cc:37:45: error: 'it' was not declared in this scope; did you mean 'int'?
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                             ^~
      |                                             int
a.cc:37:57: error: request for member 'begin' in 'pat[n]', which is of non-class type 'int'
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                                         ^~~~~
a.cc:37:79: error: request for member 'end' in 'pat[n]', which is of non-class type 'int'
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                                                               ^~~
a.cc:37:84: error: expected ')' before ';' token
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                     ~                                                              ^
      |                                                                                    )
a.cc:37:88: error: 'it' was not declared in this scope; did you mean 'int'?
   37 |                 for (list<string>::iterator it = pat[n].begin(); it != pat[n].end(); ++it){
      |                                                                                        ^~
      |                                                                                        int