Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int main()
- {
- int i,j,n,sum,m[26][26];
- srand(time(NULL));
- char a = 'A' ;
- cout<<"Enter the number of values: ";
- cin>>n;
- for(i=0; i<n; i++)
- {
- for(j=0; j<n; j++)
- {
- m[i][j]=rand()%2;
- }
- }
- for(i=0; i<n; i++)
- {
- for(j=0; j<n; j++)
- {
- cout<<m[i][j]<<" ";
- }
- cout<<endl;
- }
- sum=0;
- for(i=0; i<n; i++)
- {
- for(j=0; j<n; j++)
- {
- if(m[i][j]==1)
- {
- sum=sum+1;
- }
- }
- cout<<endl<<a <<" = "<<sum;
- sum=0;
- a++;
- }
- }
Add Comment
Please, Sign In to add comment