Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ######################## Zadanie 3 (nazwa zmiennej) ########################
- #include <iostream>
- #include <cctype>
- using namespace std;
- int main() {
- int n, i = 0;
- char zn;
- bool isGood = true;
- cin >> n;
- zn = cin.get();
- while (i <= n && isGood) {
- if (i == 0) {
- if (zn != '_' && isdigit(zn))
- isGood = false;
- }
- else if (i > 0) {
- if (isalnum(zn) == false && zn != '_') {
- isGood = false;
- }
- else {
- isGood = true;
- }
- }
- i++;
- zn = cin.get();
- }
- if (isGood) {
- cout << "To jest poprawna nazwa zmiennej";
- }
- else {
- cout << "To jest niepoprawna nazwa zmiennej";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement