Login
Register
Problem list
Online status
徐鹏
:
2024-10-06 16:16:18
#include
#include
using namespace std; int compare(string str1,string str2) { for (int i = 0; str1[i] != '\0' && str2[i] != '\0'; i++) { if (str1[i] < str2[i]) { return -1; } else if (str1[i] > str2[i]) { return 1; } else { if (str1[i + 1] == '\0' && str2[i + 1] != '\0') { return -1; } else if (str1[i + 1] != '\0' && str2[i + 1] == '\0') { return 1; } else if (str1[i + 1] == '\0' && str2[i + 1] == '\0') { return 0; }else{} } } } void function() { int T; cin >> T; string* str1 = new string[T]; string* str2 = new string[T]; for (int i = 0; i < T; i++) { cin >> str1[i]; cin >> str2[i]; } for (int i = 0; i < T; i++) { cout << compare(str1[i], str2[i]) << endl; } } int main() { function(); return 0; }
沙琪玛大王驾到
:
2024-09-29 19:42:58
#include
using namespace std; int main(){ string str1;string str2;int T=0; int arr[100]{}; cin>>T; for(int i=0;i
>str1; cin>>str2; int length1=0,length2=0; for(int j=0;str1[length1]!='\0';j++){ length1++; } for(int j=0;str2[length2]!='\0';j++){ length2++; } if(length1
length2) arr[i]=1; else{ arr[i]=0; for(int j=0;j
str2[j]){ arr[i]=1; break; } } } } for(int i=0;i
Post Your Comment