BennyExtreme

[C++] Mesi con array char

Jan 15th, 2022 (edited)
222
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int input;
  7.     char mesi[13][4] = {{'g','e','n','\0'},{'f','e','b','\0'},{'m','a','r','\0'},{'a','p','r','\0'},{'m','a','g','\0'},{'g','i','u','\0'},{'l','u','g','\0'},{'a','g','o','\0'},{'s','e','t','\0'},{'o','t','t','\0'},{'n','o','v','\0'},{'d','i','c','\0'},'\0'};
  8.     cout << "Inserisci il numero di un mese:" << endl;
  9.     cin >> input;
  10.     if (input>0&&input<13)
  11.         cout << mesi[input-1];
  12.     else
  13.         cout << "Il mese specificato non esiste!";
  14.     return 0;
  15. }
RAW Paste Data