Enter n numbers, separated by commas
The process is as follows:
char Str[100];char ch = ' str;while '; int i = 0;vector<int> v;int tmp = 0;cin >> str[i (WHI]! = Le (str[i]!= ' && str[i]! = ', ') {TMP = TMP * + str[i]-' 0 '; ++i;} V.push_back (TMP); if (str[i] = = ' \ ") break;tmp = 0;++i;}
Thunder written test Programming 2 questions
#include <iostream> #include <vector>using namespace std;int main () { int n=5; vector<int> v; char str[100]; cin >> str; int i = 0; int tmp = 0; //////////////////////////////////////handles comma-separated numbers while (str[i] != ') { while (str[i] != ' && str[i] != ', ') { if (str[i] == ' A ') str[i] = ' 1 '; else if (str[i] == ' J ' | | str[i] == ' Q ' | | str[i] == ' K ') str[i] = ' 0 ' + 10; tmp = tmp * 10 + str[i]-' 0 '; ++i; } v.push_back (TMP); if (str[i] == ') break; tmp = 0; ++i; } //////////////////////// int a[3] = { 0 }; int has = 0; for (int i = 0; i < 3; ++i) { for (int j = i+1; j < 4; ++j) { for (int K = j+1; k < 5; ++k) { if ((v[i] + v[j] + V[k]) >=10&& (V[i] + v[j] + v[k]) % 10 == 0) { a[0] = i; a[1] = j; a[2] = k; ++has; break; } } } } if (has == 0) cout << "None" << endl; else{ int sum = 0 ; for (int i = 0; i < 5; ++i) { if (I != a[0] && i != a[1] && i != a[2]) { sum += v[i]; } } if (sum >= 10 && sum % 10 == 0) { cout << "ten" &NBSP;<<&NBSP;ENDL;&NBSP;&NBSP;} else{ cout << sum % 10 << endl; } } system ("pause"); return 0;}
This article from "Zero Egg" blog, declined reprint!
Enter several numbers and separate the series of examples with commas