#307

by asd

Submitted 2 years 11 months ago
Mon May 10 19:45:49 CST 2021
Judger: judger1
Dataset Version: v1

0 ms / 0 KB
Final 0
Problem: lss4.dandelion
Language: GNU C++ 11


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int main(){
	string n;
	while(cin>>n){
	    string nn=n;
	    if(n.size()>=2){
	        n=""+n[n.size()-2]+""+n[n.size()-1];
	    }
		if(n=="11" || n=="12" || n=="13" || n=="14"){
			cout<<nn<<"th"<<endl;
			continue;
		}
		char c=n.back();
		if(c=='1'){
			cout<<nn<<"st"<<endl;
		}else if(c=='2'){
			cout<<nn<<"nd"<<endl;
		}else if(c=='3'){
			cout<<nn<<"rd"<<endl;
		}else{
			cout<<nn<<"th"<<endl;
		}
	}	
}
Compilation Error:
Main.cpp: In function ‘int main()’:
Main.cpp:44:28: error: invalid operands of types ‘const char*’ and ‘const char [1]’ to binary ‘operator+’
          n=""+n[n.size()-2]+""+n[n.size()-1];
            ~~~~~~~~~~~~~~~~^~~