Skip to content

Instantly share code, notes, and snippets.

@Marahin
Created February 9, 2015 16:45
Show Gist options
  • Save Marahin/7371f210e2dc60da4199 to your computer and use it in GitHub Desktop.
Save Marahin/7371f210e2dc60da4199 to your computer and use it in GitHub Desktop.
czarek
#include <iostream>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
/* ustawiamy, aby rand() zawsze generowal nowe liczby na podstawie czasu */
srand( time( NULL ) );
int tab[10][10],i=0,j=0,suma=0;
cout << "Generujemy liczby losowe i wypelniamy tablice" << endl;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
/* generujemy liczby i wypelanimy nimi tablice */
tab[i][j]=rand() % 100;
cout << tab[i][j] << " ";
}
cout << endl;
}
cout << "Sprawdzamy ile jest liczb dwucyfrowych." << endl;
for(int i=0; i<10; i++){
for(int j=0; j < 10; j++){
/* czy liczba jest z przedzialu <10, 99> */
if(tab[i][j]>=10 && tab[i][j]<=99){
suma++;
}
}
}
cout << "Ilosc liczb dwucyfrowych: " << suma<< endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment